Implement ISession in FluentValidation AbstractValidator

Trying to develop the best way to get NHibernate ISession in a free validation validator. The problem is that ISession is registered according to the web request, and validators are registered as monophonic according to the best performance recommendations. This, obviously, leads to the fact that problems with ISession are removed before it is needed.

Any tips that really appreciate trying to avoid passing in a container instance

+4
source share
1 answer

You can use TypedFactoryFacility, the easiest way is to use a delegate, see http://stw.castleproject.org/Windsor.Typed-Factory-Facility-delegate-based-factories.ashx

I would suggest using front-end factories, because firstly, you can explicitly free the session when you are done with it, and secondly, it is more obvious in the code that you are doing, see http: //stw.castleproject. org / Windsor.Typed-Factory-Facility-interface-based-factories.ashx

+1
source

Source: https://habr.com/ru/post/1414145/


All Articles