В C# Entity Framework 4 или 5выбрать новый производный класс от EF запроса
Entity Класс # 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.
}
Спасибо за вашу помощь.
Добро пожаловать. (Каков ваш вопрос?) – Mansfield
Создайте конструктор копирования. Вы можете сэкономить на шаблоне с чем-то вроде AutoMapper: http://automapper.org/ – millimoose