That has something to do with the concepts of referred and deferred execution in LINQ.
Context.tabls.Select(r => new tabl { code = r.code.Remove(r.code.Length - 1), resnum = r.resnum })
This part would return a
IQueryable<t> which executes only at the point when you call ToList() or iterate over the IQUeryable result for example with a foreach loop. In this case you can not map the entity to your modell. EF restricts that... I don't know why. Maybe to prevent updating / modifying entities while the result is not fully queried or fetched.
By using
AsEnumerable() the query gets executed immediately and the result is stored in the memory.
After that it is possible to map the entities to your model / class / object as the full query result is already in the memory.
It might help you to get a little inside into the referred and deferred execution in LINQ / Entity Framework.
Kind regards.