Quantcast
Channel: ADO.NET, Entity Framework, LINQ to SQL, NHibernate
Viewing all articles
Browse latest Browse all 1698

linq statement for filtering Enumeration by List of strings

$
0
0

Hello,

I have a DbSet of BowtieDMEquipmentLookups. A BowtieDMEquipmentLookup is defined as follows:

public partial class BowtieDMEquipmentLookup
{
public int BowtieDMEquipmentLookupId { get; set; }
public string EquipmentDescription { get; set; }
}

I also have a list of strings. This list of strings is supposed to match possible values in BowtieDMEquipmentLookup.EquipmentDescription.

What I want to do is get a filtered list of BowtieDMEquipmentLookups from my DbSet based on what exists in the list of strings.

For example, if my Dbset looked like this:

{
BowtieDMEquipmentLookupId = 123,
EquipmentDescription = "Pump"
},

{
BowtieDMEquipmentLookupId = 456,
EquipmentDescription = "Regeneration Column"
},

{
BowtieDMEquipmentLookupId = 789,
EquipmentDescription = "Evaporator"
}


and my list of strings looked like this:

"Pump",
"Regeneration Column"

The final list of BowtieDMEquipmentLookup should look like this:

{
BowtieDMEquipmentLookupId = 123,
EquipmentDescription = "Pump"
},

{
BowtieDMEquipmentLookupId = 456,
EquipmentDescription = "Regeneration Column"
}

How would I filter out my DbSet to get this list in a linq statement?

Thank you.


Viewing all articles
Browse latest Browse all 1698

Trending Articles