在 c# Entity Framework 4 或 5 中
实体类#1
public class ClassOne
{
public string FirstName { get;set; }
}
public class ClassTwo : ClassOne
{
public string LastName get;set; }
}
对于 IQueryable:
return from e in Context.pClassOneList from r in SomeOtherList select new ClassTwo
{
// right here how do I get all the fields assigned without having to do it manually? ie:
FirstName = e.FirstName,
LastName = r.SomeOtherVar // works perfectly, but the whole of ClassOne is not assigned unless I do it manually.
}
谢谢你的帮助。