2011-06-20 58 views
0

我有一個共同的表來存儲我的系統上的評論是這樣工作的:我如何使用EF4此表結構

id <- PK 
Text <- user content 
userId 
createdAt 
commentType <- a discriminator, to know which entity is the parent of this comment ie: N: News, A:Articles, and so on... 
typeId <- Id of the parent entity 

我使用NHibernate喜歡這個工作之前,這種類型的結構:

mapping.HasMany(x=> x.Comments) 
.Cascade.All() 
.Inverse() 
.Where("commentType='A'") 
.KeyColumn("typeId") 

我如何在EF4上使用這種類型的結構?

回答

2

我認爲this tutorial是你在找什麼。

基本上你必須爲每種描述符創建一個實體,而實體的位置在哪裏,而不是映射。