Assuming these objects ...
class MyClass { int ID {get;set;} string Name {get;set;} List<MyOtherClass> Things {get;set;} } class MyOtherClass { int ID {get;set;} string Value {get;set;} }
How to execute a LINQ to Entities Query query using a projection as shown below which will give me a list? This works fine with IEnumerable (assuming MyClass.Things is IEnumerable, but I need to use List)
MyClass myClass = (from MyClassTable mct in this.Context.MyClassTableSet select new MyClass { ID = mct.ID, Name = mct.Name, Things = (from MyOtherClass moc in mct.Stuff where moc.IsActive select new MyOtherClass { ID = moc.ID, Value = moc.Value }).AsEnumerable() }).FirstOrDefault();
Thanks in advance for your help!
c # linq-to-entities entity entity-framework
ctorx
source share