Database table relationships: Always also relate to specified value (Linq to SQL in .NET Framework)
Posted
by sinni800
on Stack Overflow
See other posts from Stack Overflow
or by sinni800
Published on 2010-04-11T19:38:52Z
Indexed on
2010/04/11
19:43 UTC
Read the original article
Hit count: 265
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?
© Stack Overflow or respective owner