Pa1
Pa1

Reputation: 630

How to compare array of elements with the linq query result in c#

How can i compare array of elements with the linq query. I will pass array of elements to the controller and i want to compare and display the records that only contains the passed elements.

I will pass an array of values like ["first","second","third"] and i want to compare these records with the linq query and generate the result that contains these three records

Upvotes: 1

Views: 1919

Answers (1)

viclim
viclim

Reputation: 959

I'm not sure but you probably want something like this

String[] values = {"first", "second", "third"};

List<YourObject> query = 
    (from p in this.db.table 
    where values.Contains(p.values) select p).ToList();

Upvotes: 2

Related Questions