Entity Framework 4: Many to Many relationship IQueryable instead of ICollection

后端 未结 1 486
名媛妹妹
名媛妹妹 2021-01-15 02:35

Good morning everyone,

I am trying to tackle a problem I run into with EF code first. My schema is the following

   public class Article : IUrlNode 
         


        
相关标签:
1条回答
  • 2021-01-15 02:59

    No there is no way to have navigation property as IQueryable but you can change the collection to IQueryable by using:

    IQueryable<Article> query = context.Entry(category).Collection(c => c.articles).Query();
    query.Where(...).Load();
    

    Generally your "algorithm" looks pretty strange. You want to work with base class but in the same time you want to access child properties. That sounds wrong and it can most probably be solved in better way (non "generic" way is also better).

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