0

I'm querying from the db below but I only need to return a record that doesn't have the age in the Agelist. But I'm stuck on how to go about and try match the age from table and age in list. Any help will be much appreciated. Thanks

List<int> AgeList = new List<int> { 61, 42, 23, 25 };
var query = Context.Table.FirstorDefault(t => t.Name == name && and t.Country ==country && t.Age != AgeList.Contains()) // I'm stuck here!!
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
1future
  • 255
  • 5
  • 21

2 Answers2

4
var query = Context.Table.FirstorDefault(t => t.Name == name && and t.Country ==country && !AgeList.Contains(t.Age))

I think that's what you're looking for

DavidWainwright
  • 2,895
  • 1
  • 27
  • 30
0

It should look like something like this : AgeList.Contains(t.Age).

If the list of int has a t.Age it will return true , if not it will return false.

Here is some documentation on Contains : https://msdn.microsoft.com/fr-fr/library/bhkz42b3(v=vs.110).aspx

Alc
  • 7
  • 3