开发者

NHibernate map to inconsistent Data

开发者 https://www.devze.com 2023-04-07 16:17 出处:网络
I am using NHibernate to map a DataModel. Unfotunatley the DataBase contains some inconsistent data due to lack of keys/constraints. Currently I am stuck with an m:n mapping where some keys on the map

I am using NHibernate to map a DataModel. Unfotunatley the DataBase contains some inconsistent data due to lack of keys/constraints. Currently I am stuck with an m:n mapping where some keys on the map Table reference missing data. Here is some sample Data:

Table: Foo
id  Value
0   A
1   B
2   C

Table: Bar
id  Value
10  X
20  Y
30  Z

Table: Map
foo_id  bar_id  amount
  0       10        2
  0       11        4
  1       12        5
  2       2开发者_高级运维0        8

I want to fetch all the Foo, that also have a Bar. In (T)SQL i would just use a join. I've tired a couple of mappings (like references + nullable, etc), but since the mapping table contains a key, NHiernate seems to expect an entity.

Any suggestions?


You could use the not-found="ignore" attribute (NotFound.Ignore() in Fluent).

0

精彩评论

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

关注公众号