请问这句SQL 怎么用linq 来写
--------------------编程问答-------------------- linq版快成翻译工具了... --------------------编程问答-------------------- 看了你的问题,困难的地方应该是在 with(nolock)读脏数据的地方,这在LINQ里也是支持的:例如:
ProductsNewViewData viewData = new ProductsNewViewData();
using (var t = new TransactionScope(TransactionScopeOption.Required,
new TransactionOptions {
IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted
}))
{
viewData.Suppliers = northwind.Suppliers.ToList();
viewData.Categories = northwind.Categories.ToList();
}
参考:
http://www.hanselman.com/blog/GettingLINQToSQLAndLINQToEntitiesToUseNOLOCK.aspx
http://madprops.org/blog/linq-to-sql-and-nolock-hints/ --------------------编程问答-------------------- var query=(from
bm in Master.where(a=>a.SiteCode =@SiteCode && a.StateCode = 78 )
join bd in Detail.where(b=>Game.where(c=>c.GroupNum = @GroupNum)).contains(b.Seq))
on bd.MasterSeq = bm.Seq into g
from k in g.De易做图tIfEmpty()
join mb in Member on mb.CN = bm.CN into m
from n in m.De易做图tIfEmpty()
select new
{
bm.Seq
,bm.CN
,bm.PrizeMoney
,bm.WinYN
,bm.Money
,bm.Cnt
}).distinct(); 你参考参考 哪写的不对还请大家指正 谢谢 --------------------编程问答-------------------- 1. 应该是 == ,而不是 =
2. Detail.where(b=>Game.where(c=>c.GroupNum = @GroupNum)).contains(b.Seq)) 这句有问题
3. join查询应该用 equals,而不是 =
4. 此处的distinct 应该使用它的重载方法,直接distinct ,在这个地方并不会起作用
5. 你忽略了SQL中的 with(nolock) --------------------编程问答-------------------- 对LINQ不是很熟悉,需要学习。帮你顶一下 --------------------编程问答-------------------- ..语句比SQL还多还不如直接用SQL --------------------编程问答-------------------- 一般来说涉及表太多的话不适合用linq,用sql更好些 --------------------编程问答-------------------- 嗯嗯 I just say oh my god! This is a maoxian and I and my friends all jingdaile --------------------编程问答--------------------
哈哈哈哈
补充:.NET技术 , LINQ