How does LINQ expression syntax work with Include() for eager loading

后端 未结 5 1512
天命终不由人
天命终不由人 2020-11-30 05:55

I have a query below, but I want to perform an Include() to eager load properties. Actions has a navigation property, User (Action.User)

1) My basic query:

5条回答
  •  再見小時候
    2020-11-30 06:21

    I use for this the LoadWith option

    var dataOptions = new System.Data.Linq.DataLoadOptions();
    dataOptions.LoadWith(ac => as.User);
    ctx.LoadOptions = dataOptions;
    

    Thats it. ctx is your DataContext. This works for me :-)

提交回复
热议问题