Working around LinqToSQls “queries with local collections are not supported” exception

后端 未结 4 1975
你的背包
你的背包 2020-12-05 09:32

So, I\'m trying to return a collection of People whose ID is contained within a locally created collection of ids ( IQueryable)

When I specify \"locally created col

4条回答
  •  情话喂你
    2020-12-05 10:21

    If Ids is a List, array or similar, L2S will translate into a contains.

    If Ids is a IQueryable, just turn it into a list before using it in the query. E.g.:

    List listOfIDs = IDs.ToList();  
    var query =  
    from st in dc.SomeTable  
    where listOfIDs.Contains(st.ID)
    select .....
    

提交回复
热议问题