views:

11

answers:

1

I have two views: one is a normal view built from one table with an integer ID and other columns for the record (let's call it View1). I have another View (View2), which has an integer ID column and a second column named "table" (type: varchar). That second column contains the name of the table to which the ID column is related: So, if View2 contains an ID of 999 and its "table" column contains the value "View1", that means the record referenced is ID 999 from View1.

Far as I can tell, DBML only allows for one-to-one or one-to-many relationships based on explicit column references; I'd rather express the relationship as a one-to-one based on the ID column AND View1.table being equal to "View2".

Is this possible? I know I can simply do an outer join in the linq query, but I'd rather avoid that if possible. Thanks!

A: 

It's not possible. The linq2sql mapper allows for mapping explicit foreign key relations, but if you don't actually have a foreign key relationship in the database, it's not possible for L2S to "infer" the relation in any way.

jeroenh
Thanks for the fast and succinct answer, much appreciated.
Matt