Hi,
I have a SQL database (SQL Server 2008) which contains the following design
ITEM
- ID (Int, Identity)
- Name (NVarChar(50))
- Description (NVarChar(200))
META
- ID (Int, Identity)
- Name (NVarChar(50))
There exists a N-N relationship between these two, i.e an Item can contain zero or more meta references and a meta can be associated with more than one item. Each meta can only be assocated with the same item once. This means I have the classic table in the middle
ITEMMETA
- ItemID (Int)
- MetaID (Int)
I would like to to execute a LinqToSql query to extract all of the item entities which contains a specific set of meta links. For example, give me all the Items which have the following meta items associated with it
- Car
- Ford
- Offroad
Is it possible to write such a query with the help of LinqToSql? Let me provide some more requirements
- I will have a list of Meta tags I want to use to filter the items which will be returned (for example in the example above I had Car, Ford and Offroad)
- An item can have MORE meta items associated with it than what I provide in the match, i.e if an item had Car, Ford, Offroad and Red assocated to it then providing any combination of them in the filter should result in a match
- However ALL of the meta names which are provided in the filter MUST be assocated with an item for it to be returned in the resultset. So sending in Car, Ford, Offroad and Red SHOULD NOT be a match for an item which has Car, Ford and Offroad (no Red) associated with itself
I hope its clear what I'm trying to achieve, I feel Im not being quite as clear as I'd hoped =/ Let's hope its enough :)
Thank you!