【发布时间】:2016-06-04 04:30:04
【问题描述】:
假设我有以下(更复杂的真实情况)CLR 对象:
class Student {
public int Id {get;set;}
public int Age {get;set;}
public string Name {get;set;}
public ICollection<Grade> Grades {get;set;}
}
class Grade {
public int Id {get;set;}
public int Grade {get;set;}
public string Course {get;set;}
public virtual Student Student {get;set;}
public int StudentId {get;set;}
}
还有以下存储过程:
SELECT *
FROM Students AS S
INNER JOIN Grades AS G ON S.Id = G.StudentId
如何从 Entity Framework 执行查询,以使结果值成为 Students 的集合,其中填充了 Grades 集合?
显然,这可以通过使用实体框架实体直接实现,但实际情况要复杂得多,生成的 EF 查询比实现相同查询的存储过程多 100 倍以上的时间。我唯一的问题是当它返回时如何接收数据
【问题讨论】:
标签: sql entity-framework stored-procedures entity-framework-6