NHibernate map to inconsistent Data
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).
精彩评论