Given the follwing:
SQL Tables:
Names
-----
Id (int)
FirstName (varchar)
LastName (varchar)
NameProperties
----------
Id (int)
NameId (int) FK to Names Id
PropType (int)
PropValue (int)
Every Name can have multiple NameProperties
Now my searchCriteria Class is as follows
public string FirstName { get; set; }
public string LastName { get; set; }
public List<KeyValuePair<int,int>> Properties { get; set; } Corresponding to a list of PropType ProValue
How do I search using linq to EF when having multiple PropType & PropValues ?
Supposing that the criteria in
Propertiesshould all be met (i.e.ANDand notOR) you could do this:(not checked for syntax, just showing the idea).
It is not very efficient to query this way, but querying an Entity–attribute–value model is always a pain. If it is even remotely possible to change the Name table in a way that it includes columns corresponding with the NameProperties then do it.