How do I just LINQ Join() to link two IQueryables?

后端 未结 1 1417
星月不相逢
星月不相逢 2020-12-30 04:09

I have two IQueryables:

Ingredient:

IngId
Description

AvailableIngredient:

IngId
         


        
1条回答
  •  别那么骄傲
    2020-12-30 04:56

    Use the first query as the source of the subsequent query.

    IQueryable query = from item in context.Ingredients
                                 // Quite a few `where` clauses and stuff
                                   select item;
    
    if (filterByAvailable)
    {
        IQueryable availableQuery = GetAvailableIngredientQuery(context);
        query = from item in query
                join t in availableQuery on item.IngId equals t.IngId
                select item;
    }
    

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