Entity Framework 4 - What is the syntax for joining 2 tables then paging them?

后端 未结 4 1993
遇见更好的自我
遇见更好的自我 2021-02-03 22:54

I have the following linq-to-entities query with 2 joined tables that I would like to add pagination to:

IQueryable data = from inventory         


        
4条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-03 23:39

    Define the join in your mapping, and then use it. You really don't get anything by using the Join method - instead, use the Include method. It's much nicer.

    var data = objContext.ProductInventory.Include("Variant")
                   .Where(i => i.ProductId == productId && i.StoreId == storeId)
                   .OrderBy(j => j.Variant.SortOrder)
                   .Skip(x)
                   .Take(y);
    

提交回复
热议问题