I want to return one element from my context as follows
using (var context = new MyContext()) { var person = context.People.OrderByDescending(x => x.LastUpdatedDate).FirstOrDefault(); }
My context looks like this:
public DbSet<Person> People { get; set; }
Why is the variable type my person above not Person , but the type of dynamic proxy, for example System.Data.Entity.DynamicProxies .Person_5E43C6C196972BF0754973E48C9C941092D86818CD94005E9A759B70BF6E48E6 ?
If I use Find , then I get the type as Person . I want to return the first record, as ordered by the last update date, and OrderByDescending / FirstOrDefault seemed the most logical.
I understand that I can turn off dynamic proxy generation, but I donโt think it is necessary.
Suppose my question is, which linq methods force the object to return as the type you expect and which returns a dynamic proxy type?
source share