public class baseEntity
{
[Key]
public int ID { get; set; }
public string Name { get; set; }
}
public class ProjectEntity : baseEntity
{
public string Address { get; set; }
public string PhoneNo { get; set; }
}
public class ProcessEntity : baseEntity
{
public string TypeName { get; set; }
public int Steps { get; set; }
}
public class DBContext : DbContext
{
public DBContext() : base("DefaultConnection")
{
}
public DbSet<baseEntity> BaseEntities { get; set; }
}
DBContext db = new DBContext();
var list = from p in db.BaseEntities select p
이 필드는 BaseEntity, ProcessEntity 또는 ProjectEntity 인 모든 항목을 기초로 사용합니다.ef는 기본 클래스에서만 필드를 가져옵니다.
필드를 BaseEntity (ID, Name 만)로 가져 오려면 어떻게해야합니까?
var list = from p in db.BaseEntities select new {p.ID,p.Name}
이것은 내가 원하는 것이 아닙니다. 내 프로젝트에 많은 필드가 있기 때문에. 나는이
var list = from p in db.BaseEntities select new {p.ID,p.Name,p.xxx .....................}
of type은이 직업을 끝낼 수 있습니다. 감사합니다. – iwaitu