0
我有一个非常简单的资源库,我在玩VS2010 Beta 2的Entity Framework v4。如何在此代码中执行此Eager加载(使用.Include()方法)?
我试图动态地包含Include方法,如果用户可选地请求它。
例如。
Public IQueryable<Foo> GetFoos(bool includeBars)
{
var entites = new Entities("... connection string ... ");
var query = from q in entities.Foos
select q;
if (includeBars)
{
// THIS IS THE PART I'M STUCK ON.
// eg. query = from q in query.Include("Bars") select q;
}
return (from q in query
select new Core.Foo
{
FooId = q.FooId,
CreatedOn = q.CreatedOn
});
}
任何人都可以请帮忙吗?