contains in linq query

前端 未结 4 407
青春惊慌失措
青春惊慌失措 2021-01-16 01:59

Hi i am using entity framework and LinQ. I have a table objects called users . i have a list called userids. i have to find all users where ids contains in the string. I hav

4条回答
  •  遥遥无期
    2021-01-16 02:35

    Assuming userids is an IEnumerable of the same type as User.userid, try changing your LINQ query to:

    var u = context.users.Where(o=> userids.Contains(o.userid)); 
    

提交回复
热议问题