2

I am trying to use "contains" in my LINQ query, but dont see "contains" keyword in LINQ. I have the following table called "Document" in the sql dataabase:

Document Row1 Row2 1 X 2 Y 3 Z 

I want to achieve this in LINQ:

select count(*) from document where Row1 in (1,2,3)

I wrote LINQ this way:

var count = await ( from doc in _Context.Document where doc.Row1.contains 

I get an error saying int? does not contain the defination for "contains". Row1 is defined as an integer in the database. I need to put multiple values for Row1.

any help will be appreciated.

1

1 Answer 1

3

The Contains method is available for a List, so your code should look like this:

var list = new List<int> {1,2,3}; var count = await ( from doc in _Context.Document where list.Contains(doc.Row1) ); 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.