开发者

Mapping an entity to more than one table (EF4, WCF RiaServices) - Internationalization

if I understood several other posts correctly it's currently not possible to map an entity to more than one table if they do not share the same primary key.

Is this still true? What I'm wondering is how internationalization should be handled with the db design below and EF.

I've a internationalized db where texts are stored in separate tables. e.g.

CREATE TABLE Product(
 ProductID int IDENTITY(1,1) NOT NULL,
 ProductGroupID int NOT NULL,
 ...
 CONSTRAINT PK_Product PRIMARY KEY CLUSTERED 
(
 ProductID ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON PRIMARY
) ON PRIMARY

CREATE TABLE Product_i18n(
 ProductID int NOT NULL,
 LanguageID int NOT NULL,
 ProductName nvarchar(150) NULL,
 Descri开发者_Go百科ption nvarchar(max) NULL,
 ...
 CONSTRAINT PK_Product_i18n PRIMARY KEY CLUSTERED 
(
 ProductID ASC,
 LanguageID ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON PRIMARY
) ON PRIMARY

So the product consists of two tables. In the table Product the language independent part is stored and in the table Product_i18n the language dependend part is stored. The two tables are physically linked with a 1:n association, but logically it's a 1:1 association because I always need one language at a certain operation.

Therefore I would like to combine the two tables in a single entity Product which consists of the columns

  • ProductID
  • ProductGroupID
  • LanguageID
  • ProductName
  • Description ...

If this would be possible I could keep the internationalized table out of my model to make it more clear.

Is this possible with EF4. Any guidance and experiences with internationalization to solve this issue are welcome.

Thanks a lot

Uwe


I don't know if you are still having the problem, but you can solve it using a view for your products, more accurate, one view for each language.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜