有效地请求多个实体

时间:2015-04-14 21:09:14

标签: c# entity-framework-6

我需要请求没有关系的不同实体的列表(为了创建该关系)。例如:

var attributeGroups = db.Attribute_Group.Where(g => attributeGroupIds.Contains(g.Id));
var attributes = db.Attribute.Where(g => attributeIds.Contains(g.Id));

当我稍后迭代结果时,它会进行多次数据库调用吗?有没有办法只做1?

1 个答案:

答案 0 :(得分:0)

您唯一的选择是调用返回多个结果集的存储过程。见http://romiller.com/2012/08/15/code-first-stored-procedures-with-multiple-results/

相关问题