Reputation: 47387
I have an integer list
''# VB
Dim ResultIDsas List(Of Integer) = new List(Of Integer)
// C#
List<int> ResultIDs= new List<int>();
I add to that list by looping through the results of a Lucene Read.
''#VB
While (i <= (page * 10) AndAlso i < HitCollection.Length)
Dim document As Document = HitCollection.Doc(i)
Dim _event As New Domain.[Event]
ResultIDs.Add(document.[Get]("ID"))
i += 1
End While
// C#
while ((i <= (page * 10) && i < HitCollection.Length)) {
Document document = HitCollection.Doc(i);
Domain.Event _event = new Domain.Event();
ResultIDs.Add(document.Get("ID"));
i += 1;
}
Now here's where the question comes in.
Say my List of Integers is [1,5,6,19,22]
What would a linq (lambda) expresion look like when I need to query my service?
''# VB
EventService.QueryEvents().Where(Function(e) (e.ID = 1))
// C#
EventService.QueryEvents().Where((System.Object e) => (e.ID == 1));
// Obviously these will simply grab ID of "1" which is not what we want.
Upvotes: 2
Views: 4017
Reputation: 18335
I'm taking a guess here, but this seems to be what you're after.
''# VB.NET
EventService.QueryEvents().Where(Function(e) (ResultIDs.Contains(e.ID))
And in C#:
// C#
EventService.QueryEvents().Where((System.Object e) => (ResultIDs.Contains(e.ID)));
Upvotes: 1
Reputation: 6814
EventService.QueryEvents().Where(e => list.Contains(e.ID));
this would generate the equivalent of SELECT ... WHERE e.ID in (1,5,...)
Upvotes: 2