You can do this using a nested where clause You need to filter p. PropertyPets using contains return all rows where PetID is in search. PetType Then only return rows from properties where all search id's have been found - eg number of rows >= number of serach id's All together: var result = from p in properties where p.PropertyPets.
Where(c => search.PetType. Contains(c. PetID)).Count() >= search.PetType.Count() select p.
You can do this using a nested where clause. You need to filter p. PropertyPets using contains - return all rows where PetID is in search.PetType.
Then only return rows from properties where all search id's have been found - eg number of rows >= number of serach id's All together: var result = from p in properties where p.PropertyPets. Where(c => search.PetType. Contains(c.
PetID)).Count() >= search.PetType.Count() select p.
Geoff - It works! Thank you. Very concise and looking pretty creative to boot.
– Chris Feb 24 at 16:57 @Chris - No problem. Happy to help :) – Geoff Appleford Feb 24 at 18:01.
For the part where Contains requires a string would not be true, Contains should require an int if your search. PetType is int. That means that you need to "convert" p.
PropertyPets into an int. To convert p. PropertyPets to IEnumerable you need to select the PropertyID field: p.PropertyPets.
Select(propertyPet => propertyPet. PropertyID), but that won't get you a single int as required but a whole bunch. (.First() would give you one int but not solve your problem.
What you really want to do is var result = properties. Where(p => search.PetType. Except(p.PropertyPets.
Select(propertyPet => propertyPet. PropertyID)).Count() == 0); But Except is not available in LINQ2SQL. The best option I can find is to apply Contains for each item in search.PetType.
Something like this: var result = properties; foreach(var petType in search. PetType) { result = from p in result where p.PropertyPets. Select(propertyPet => propertyPet.
PropertyID). Contains(petType) select p; }.
Albin- This didn't work for me. Conceptually, it seems like it ought to. I added a 'Select p' at the end as the compiler was complaining, but still no go.
Result ends up with no properties even if I select a pet that the property does have. – Chris Feb 24 at 16:51.
Var secondBody = ParameterRebinder. Body, secondBody), first. Expression> predicate = PredicateBuilder.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.