请问Spring.Net是否内置了对Linq2SQL的支持?Spring.Net 论坛上有人提到 NHibernate 有一个桥梁。但是,我可能根本不使用 NHibernate。我正在寻找对 Linq2Sql 的直接支持。
如果我正在使用TxScopeTransactionManager
基于属性的事务并将其应用于包含两个 linq2sql 调用的业务方法,该事务是本地事务还是升级为分布式事务?
请问Spring.Net是否内置了对Linq2SQL的支持?Spring.Net 论坛上有人提到 NHibernate 有一个桥梁。但是,我可能根本不使用 NHibernate。我正在寻找对 Linq2Sql 的直接支持。
如果我正在使用TxScopeTransactionManager
基于属性的事务并将其应用于包含两个 linq2sql 调用的业务方法,该事务是本地事务还是升级为分布式事务?
我建议使用ConnectionUtils
及其GetConnectionTxPair
方法。它返回一对数据库连接和附加到它的事务。DataContext
当您引用事务时,您可以通过简单地设置Transaction
此上下文的属性来显式地将 LINQ2SQL加入其中。
您可以扩展AdoTemplate
以支持 LINQ2SQL:
public delegate T DataContextDelegate<T>(DataContext command);
public class LinqAdoTemplate : AdoTemplate
{
public virtual T Execute<T>(DataContextDelegate<T> del)
{
ConnectionTxPair connTxPair = ConnectionUtils.GetConnectionTxPair(DbProvider);
using (var context = new DataContext(connTxPair.Connection))
{
//downcast is a bit smelly here
//one can throw exception though when connTxPair.Transaction is of invalid type
context.Transaction = connTxPair.Transaction as DbTransaction;
return del(context);
}
}
}
然后,您可以配置 Spring.NET 以将其注入您的 AdoTemplate 感知对象。
我想知道同样的事情。我在这里做了一个快速搜索:
http://jira.springframework.org/secure/QuickSearch.jspa
和这里:
http://forum.springframework.net/search.php?do=process
什么也没发生。它不在 1.3 中,而且似乎不在 2.0 的路线图中。