0

I have a table(DbSet) called 'Submission' and a List(Of Integer) containing a selection of primary keys from the Submission table.

How do I filter down the DbSet to return an IENumerable(Of Submission) for all Submissions with a primary key in the List of integers?

If I wanted just one Submission I would do the following:

Dim db As New MyEntities
Dim result As Submission

result = db.Submission.Find(key)
Return result

What I actually need is something like this (obviously not using the code below though as it wont work):

Dim db As New MyEntities
Dim keys As List(Of Integer)
Dim results As IENumerable(Of Submission)

results = db.Submission.Find(keys)
Return results

Many thanks in advance for any assistance!!

1 Answer 1

3

This is the C# syntax, but:

result = db.Submission.Where(s => keys.Contains(s.Id));
Sign up to request clarification or add additional context in comments.

1 Comment

Wow, how on earth did I miss that?!? Thank you so much!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.