views:

27

answers:

1

I really can not describe my question better in the title. If anyone has suggestions: Please tell!

I use the Linq to SQL framework in .NET. I ran into something which could be easily solved if the framework supported this, it would be a lot of extra coding otherwise:

I have a n to n relation with a helper table in between. Those tables are: Items, places and the connection table which relates items to places and the other way. One item can be found in many places, so can one place have many items.

Now of course there will be many items which will be in ALL places. Now there is a problem: Places can always be added. So I need a place-ID which encompasses ALL places, always. Like maybe a place-id "0". If the helper table has a row with the place-id of zero, this should be visible in all places. In SQL this would be a simple "Where [...] or place-id = 0", but how do I do this in Linq relations?

Also, for a little side question: How could I manage "all but this place" kind of exclusions?

A: 

In Linq to Sql the relationships between the entities as defined in the dbml layout cannot be quantified in the way you are describing. You could write a method in a partial class that uses the linq join syntax, and delete the relationship from the diagram.

Alternatively you could use the entity framework instead of linq to sql as the relationships can be defined in more advanced ways on the diagram.

SteadyEddi
Hmmm. Alright, I will try those two suggestions out and see...
sinni800