Dynamic Expression using LINQ. How To Find the Kitchens?

前端 未结 5 1854
难免孤独
难免孤独 2021-01-04 23:29

I try do implement a user dynamic filter, where used selects some properties, selects some operators and selects also the values.

As I didn\'t find yet an answer to

5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-05 00:26

    what about this

    var kitchens = houses
                    .SelectMany(h => h.Rooms, (h, r) => new {House = h, Room = r})
                    .Where(hr => hr.Room.Type == RoomType.Kitchen)
                    .Select(hr => hr.House);
    

提交回复
热议问题