开发者

How can i add some sql to all querys in NHibernate

开发者 https://www.devze.com 2022-12-21 00:27 出处:网络
I want a version control system and therefore all querys must add a piece of sql In place for the current record 开发者_Go百科shows.

I want a version control system and therefore all querys must add a piece of sql

In place for the current record 开发者_Go百科shows.

But what place, can i add that piece of sql to all querys ? or could i do it with events?


Make a class that implements IInterceptor

then give that class as param to the session like

SessionManager.SessionFactory.OpenSession(new newClass()));

in the class you need to give your implementation to

public NHibernate.SqlCommand.SqlString OnPrepareStatement(NHibernate.SqlCommand.SqlString sql)
{

}

each query that will run on this session will be intercept here and there you can add some sql

0

精彩评论

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

关注公众号