Linq Where inside a where

tom clack

I want to compare the values inside the ids array with the ItemID value in the ItemsOfCars table. ItemsOfCars is a table relationship to many to many.

As an example, I have values 1,2,3,4,5 in ItemsOfCars. I have values 1, 2 in the array named ids. I want to compare them and get the values 3, 4, 5 that are in the ItemsOfCars array but not in the ids array.

    [HttpPost]
    public IActionResult GetItems(int[] ids)
    {
       
       foreach (var item in items)
        {
            item.ItemsOfCars.Where(x => x.ItemId == ids)
        }
    }

enter image description here enter image description here enter image description here

Sergey

try this:

public IActionResult GetItems(int[] ids)
    {
   
      var items=  ItemsOfCars.Where(i => !ids.Contains(i.ItemId)); 
    }

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事