Trying to join a list and SQL table using Linq. Contains method still gives local sequence error cannot be used

I am trying to join a table and list in LINQ. From the posts in stackoverflow, I know that you cannot select from a table and list using a join - that you should use .contains. But when I use .contains, I get the same error. What else am I missing? Am I trying to do what Linq will not support? Should I just write a support function that will cycle through daily entries at a time (eliminating the need for a connection)?

This is my code:

Dim count = (from sqlRec in mydatacontext.table, listItem in myList where _ sqlRec.guidIdField.ToString.contains(listItem.IdProperty.toString select sqlRec).count 

It gives the same error that I tried to fix, which reads: "The local sequence cannot be used in LINQ to SQL implementations of query operators except the Contains statement."

I am trying to do this (of course, the syntax below will not work):

 (from sqlRec in table, listItem in List where sqlRec.guid=listId.Id select sqlRec).count 
0
source share
1 answer

You should use Contains in local sequence:

 Dim count = mydatacontext.table.Where(Function(sqlRec) _ myList.[Select](Function(x) _ listItem.IdProperty.ToString()) _ .Contains(sqlRec.guidIdField.ToString())).Count() 
0
source

Source: https://habr.com/ru/post/1487439/


All Articles