Select items by tag when searching multiple tags

前端 未结 2 1785
挽巷
挽巷 2020-12-20 09:20

I\'m struggling a bit here so I thought why not ask:

Every entity in my system has a list of tags (a list of strings), and I want to be able to search for multiple t

2条回答
  •  再見小時候
    2020-12-20 09:54

    Not sure I really understand what you're asking, but maybe something like the following would work.

    List searchTags = ...
    
    var query = db.MyEntity
                  .Where( e => e.Tags.Intersect( searchTags ).Count() > 0 );
    

    This should give you the set of entities where the list of tags contains at least one of the items in searchTags

提交回复
热议问题