0

I'm dealing with a legacy db, which uses dummy records for some empty relations.

Example: article has a relation to supplier. If an article has no supplier, a dummy supplier with ID 0 is assigned to the article, to satisfy the relation between both tables.

When adding a new article via nhibernate, I have to load and assign this dummy supplier to the new article. I would prefer being able to add a new article and leave the supplier field as NULL.

So I'm looking for a solution to transparently transform NULL to this dummy record and vice versa. With help of this question I was able to do the conversion from NULL to the dummy record, but how can I hide the dummy entity in my code?

Community
  • 1
  • 1
Geiserich
  • 358
  • 1
  • 7

1 Answers1

0

You can do this by adding a filter to your entities and enable the filter in your session.

nhibernate-filters

Peter
  • 27,590
  • 8
  • 64
  • 84