1

如何使用 Linq2Sql 上下文在 linq 中编写此查询?

select SUM(ORDERQTY * MULTIPLIER) AS VOL_USD
   from Executions with (nolock)
where TRANSACTTIME >= '2013-08-01 00:00:00'
and TRANSACTTIME < '2013-09-01 00:00:00'
and MTCONTEXT in (5,6)
and ORDERQTY > 0
AND SOURCE = 'INTMT'
and LEFT(SYMBOL, 3) = 'USD'

是否可以让 Linq2Sql 生成的查询与纯 sql 查询相同?

4

1 回答 1

1

你可以使用这样的东西

using (var ts = new TransactionScope(TransactionScopeOption.Required,
                new TransactionOptions {IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted}))
{
    var result = DbContext.Executions.Where(/*...condition...*/).Sum(o=>o.ORDERQTY * o.MULTIPLIER)
}
于 2014-01-11T03:35:03.813 回答