Not finding .Include() method in my EF implementing Generic repository

前端 未结 1 1797
孤街浪徒
孤街浪徒 2021-02-15 16:33

I am using Generic repository to wrap DbContext and DbSet classes from upper level. However, when in certain queries I need to use \".Include()\" method to include navigation pr

1条回答
  •  孤街浪徒
    2021-02-15 16:59

    Include for IQueryable is an extension method that is implemented in namespace System.Data.Entity in the assembly EntityFramework.dll. So your project must reference this assembly and you must add

    using System.Data.Entity;
    

    at the beginning of your code file. It will make the string and lambda based version of Include available, so that you can use:

    orderQuery.Include("Customer")
    

    or

    orderQuery.Include(o => o.Customer)
    

    0 讨论(0)
提交回复
热议问题