我的 Telerik OpenAccess ORM 有一些(更多)问题。这次是在将 Fetch Strategies 应用于查询的领域。这是代码...
using (DAL.DarkRoomDB ctx = new DarkRoomDB())
{
//
// Set the resulting object to include the contents of the package
FetchStrategy strategy = new FetchStrategy();
strategy.LoadWith<DeliverablePackageEntity>(c => c.PackageContents);
strategy.LoadWith<DeliverablePackageContentEntity>(c => c.Deliverable);
strategy.LoadWith<DeliverablePackageContentEntity>(c => c.DeliverablePackage);
strategy.MaxFetchDepth = 3;
ctx.FetchStrategy = strategy;
//
// get the package that matches the SKU
DataStoreRepository<DeliverablePackageEntity> repo = DataStoreRepository<DeliverablePackageEntity>.GetInstance(ctx);
DeliverablePackageEntity entity = repo.GetEntityList(c => c.PackageSku == SKU).FirstOrDefault();
//
// Create a DISCONNECTED COPY of the entity
copy = ctx.CreateDetachedCopy<DeliverablePackageEntity>(entity, strategy);
}
ret = EntityToDomainMapper.Map<DeliverablePackageEntity, DeliverablePackage>(copy);
return ret;
当我运行它时,我希望预加载DeliverablePackageEntity的PackageContents 。但是,当我在调试器中查看实体变量时,它告诉我“扩展时将枚举属性的内容”,这表明该属性尚未预先填充,这就是我认为的目的FetchStrategy 是。
我错过了什么吗?