Entities LoadOptions
问题:
DataLoadOptions 好像是 只能再 Linq to SQL里边用,我想在Entities里边实现类似的效果该怎么办?
我在Entities里边用出现了错误:
错误11“WebVOD.Models.WEBVODEntities”不包含“LoadOptions”的定义,并且找不到可接受类型为“WebVOD.Models.WEBVODEntities”的第一个参数的扩展方法“LoadOptions”(是否缺少 using 指令或程序集引用?)F:\win2008iis\BYVOD\Models\LibraryBLL.cs25221BYVOD
原来在Linq to SQL用的:
public static PagedList<FavoriteVideo> GetPagedFavoriteVideosByLoginName(string loginName, int pageIndex, int pageSize)
{
using(var db=new WebVODDataContext())
{
db.ObjectTrackingEnabled = false;
var dlo=new DataLoadOptions();
dlo.LoadWith<FavoriteVideo>(f=>f.Video);
dlo.LoadWith<Video>(v=>v.VideoCategory);
dlo.LoadWith<Video>(v=>v.Album);
db.LoadOptions = dlo;
return db.FavoriteVideos.Where(f => f.LoginName == loginName).OrderByDescending(f=>f.DateAdded).ToPagedList(pageIndex, pageSize);
}
}