I have many, many tabular structures called PropertyPets. It contains a double primary key consisting of a PropertyID (from the property table) and one or more PetID (from the pet table).
Next, I have a search screen in which people can select multiple pets from the jquery multiple select drop-down list. Let's say someone chooses dogs and cats.
Now I want to be able to return all properties containing the BOTH of dogs and cats in many PropertyPets tables. I am trying to do this from Linq to Sql.
I looked at the Contains suggestion, but it doesn't seem to work for my requirement:
var result = properties.Where(p => search.PetType.Contains(p.PropertyPets));
Here, search.PetType is an array of int [] identifiers for the dog and cat (which was selected from the drop-down list of several items). First problem: Contains requires the string to not be an IEnumerable of PropertyPet type. And secondly, I need to find properties that have BOTH dogs and cats, and not just just one or the other.
Thanks for any pointers.
source
share