开发者

Linq2Sql Nullable association

开发者 https://www.devze.com 2023-01-27 09:28 出处:网络
In multi-language project I have the following DB structure in SQL2005: table StringTable: itemID int PK,

In multi-language project I have the following DB structure in SQL2005:

table StringTable:

   itemID int PK,
   stringID int NOT NULL,
   stringValue nvarchar,
   languageId int

table Articles:

   articleID int PK,
   titleID int NOT NULL (FK to StringTable.stringID),
   descriptionID int NULL (FK to StringTable.stringID)

I have trouble mapping the Articles.descriptionID->StringTable.s开发者_如何转开发tringID association in Linq2Sql (using the designer).. is says : "The parent property cannot be nullable if the child is nullable"... which I understand... but in my case the descriptionID needs to be nullable. Can anybody help me with this issue or propose a workaround (using L2Sql and C#), I'm open to minor DB structure modifications too if it helps the case.

ps. All I need is a Descriptions property for the Article object which contains the descriptions (in all languages) of the given article or NULL.


Had the same problem - solved by add the association to the other table.

0

精彩评论

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

关注公众号