Wom*_*bat 0 c# nhibernate fluent-nhibernate
我正在尝试为以下问题构建映射.案例可以有多个客户端,客户端可以附加到多个案例.
我有这些映射:案例
Map(x => x.CaseNumber);
References(x => x.Status).Cascade.All();
HasManyToMany<Client>(x => x.Clients)
.Table("CaseToClient")
.Access.CamelCaseField(Prefix.Underscore)
.Cascade.SaveUpdate()
.LazyLoad();
Run Code Online (Sandbox Code Playgroud)
现在我的CaseToClient表由Case_Id和Client_Id组成我想要的是表中的另一列,其中客户端的boolen与案例相关.如何添加列以便我可以编写属性?
不要使用多对多,使用两个一对多映射.
为ClientCase创建一个单独的实体,它引用Case和Client,并且还有你的boolean属性.
From NHibernate In Action, page 193:
"we avoid the use of many-to-many associations because there is almost always other information that must be attached to the links between associated instances; the best way to represent this information is via an intermediate association class."