开发者

NHibernate CreateSQLQuery Transaction Issue

开发者 https://www.devze.com 2022-12-08 12:46 出处:网络
I have a simple method that does... Session.CreateSQLQuery(syntax).List<T>(); The issue is that when I execute this against a stored procedure that enlists a linked se开发者_如何学运维rver co

I have a simple method that does...

Session.CreateSQLQuery(syntax).List<T>();

The issue is that when I execute this against a stored procedure that enlists a linked se开发者_如何学运维rver connection I get the following error...

The operation could not be performed because OLE DB provider "MSDASQL" for linked server "MyLinkedServer" was unable to begin a distributed transaction.

My question is; how can I tell NHibernate I do not want to use a transaction..?

Thanks..!


I usually do like this:

session = PersistenceManager.GetCurrentSession();                
IList<T> lst;
using ( var trans = session.BeginTransaction() )
{
    IQuery sql = session.CreateSQLQuery(syntax);
    lst = slq.List<T>();
    trans.Commit();
}
0

精彩评论

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