tags:

views:

104

answers:

0

Hi,

I have the following DB structure, which is not something I can change:

Product table: IdProduct, Price,....etc

Product Description table: IdProductDescrition, IdProduct, IdLiteral,...etc

Category Table: IdCategory, IdLiteral

Literals Table: idLiteral, idLanguage, literal


The Literals table holds the value of literals in several languages of all the tables. It uses the "IdLiteral" field to map to the correct table in the way:

Product.Id=1

Product.IdLiteral= "Product_1"

Category.Id=1

Category.IdLiteral= "Category_1"

And table literals has this values in its primary key field:

Literal.IdLiteral="Product_1" (and this is unique)

So this way, when I need a specific literal, I do something like "where Products.Idliteral= Literals.IdLiteral and Literals.IdLanguage=1"

The primary key of table literals is composed by: IdLiteral and idLanguage

So, the relationship between Literals and the other tables is like a foreign key, but not to one table, but to all the tables that use the Literals... Of course, the foreign key doesnt exist really... but the logical relation is there...

I added associations in linq designer, maping the fields "idliteral" of each table so ProductDescription and Categories can hold a reference to Literals... The problem is that Literals is really a EntitySet not an EntityRef, because it holds one record for every language in the table... But the designer does not recognize that the primary key of table literal is composed by two fields, and so, the association should be an entityset... It generates the association as a entityref. What can I do to make it an entityset without changing the generated code?

Well, I'm not sure if I've been enough clear explaining my situation because my english is not very good.... and I'm begining to LINQ...

I would like to know which is the best way to manage this kind of relationship in LINQ... Besides, I'm having big trouble for loading all the object graph at once... The LoadWith method of DataLoadOptions works only for 1st level associations... But that will be another post in the forum...

THANKS,

seb.