Entity Framework - Eager loading related entities

后端 未结 4 1368
野趣味
野趣味 2021-02-13 19:17

I\'m using Entity Framework 4 with MVC and need to ensure any referenced entities I want to use in my view have been loaded before the controller method returns, otherwise the v

4条回答
  •  清酒与你
    2021-02-13 19:49

    I think this is a job for your repository which should in your case expose methods like GetFullSeller (all properties loaded by Include) and GetSeller (only base entity).

    Edit:

    There are several ways how to load navigation properties in EF v4.

    • Eager loading (using Include)
    • Lazy loading
    • Explicit loading by ObjectContext.LoadProperty (doesn't work for POCO)

    There is no automatic loading.

提交回复
热议问题