3

I have a function import that is returning me a dataset of type Package which has a property called PackageRoles with is a foreign key reference to a list of PackageRole objects.

When I call my function import like this...

List<Package> orders = db.GetTopOrders();

I get my list but PackageRoles property has not been populated.

Is there a way of getting this to populate using an Include() for example? I need to be able to get these without wanting to iterate over the Packages ideally.

4

1 に答える 1

2

私はそれを行う方法を見つけることができないので、このアプローチに落ち着きました。結果を List<> に列挙してから、リストを反復処理し、ObjectContext で LoadProperty を使用して必要なプロパティを読み込みます。

List<Package> orders = db.GetTopOrders().ToList();

foreach (var order in orders)
{
    db.LoadProperty<Package>(order, o => o.PackageRoles);
}
于 2012-08-14T13:00:07.793 に答える