nhibernate / nhibernate-core

NHibernate Object Relational Mapper
https://nhibernate.info
GNU Lesser General Public License v2.1
2.13k stars 929 forks source link

NH-2874 - Support Where Clause in Many To One Associations #903

Open nhibernate-bot opened 7 years ago

nhibernate-bot commented 7 years ago

Ricardo Peres created an issue — :

It would be useful if we could specify a where clause for many to one associations, like there is for one to many. The main reason I see for this is because of soft deletes: if an entity has a where clause specified that filters out soft deletes, one can still load entities that are soft deleted through a many to one that uses join, in this case, the entity's where clause is not applied.

manureini commented 4 years ago

Hello ;)

Is there still now way to handle this? I'm facing the same problem. If you are using soft delete you must specify .Where(o => !o.IsDeleted) on every query and every access to a Collection of an object.

Edit: After some investigation I found out that filters can be used for that. https://nhibernate.info/doc/nhibernate-reference/filters.html