linq 子查询中怎么使用Isnull
--------------------编程问答-------------------- http://social.msdn.microsoft.com/Forums/zh-CN/linqtosql/thread/096b5866-8511-4d48-bbe6-913f0d498c06 --------------------编程问答--------------------select new
{
Charge=cr.isend==null?"未收":cr.isend==1?"欠费":"已收"
} --------------------编程问答-------------------- 楼上很详细! --------------------编程问答-------------------- linq 直接可以写程序一样==null的啊 --------------------编程问答-------------------- 我的SQL语句没有写完整
应该是这样的
select--------------------编程问答--------------------
....
Charge=isnull((SELECT Charge=case when cr.isend=1 then '欠费' else '已收' end
FROM TCharge tc Where tc.code=t.code),'未收')
from task t
left join ....
left join ....
where ....
2楼的不行? --------------------编程问答-------------------- var q=
from a in task
join b in db.Orders on a.ID equals b.ID into ords
join c in db.Employees on a.ID equals c.ID into emps
select new { Charge=b.isend==null?"未收":b.isend==1?"欠费":"已收"};
借用二楼的的,字段需要改大概就是这个样子吧 --------------------编程问答-------------------- 首先在Linq中没有isnull函数,在子查询中new出的东西
可以在里面进行判断(我一般用三元),也可以在里面连接别的查询 --------------------编程问答-------------------- --------------------编程问答-------------------- 根据条件过滤以后,用VAR接收,然后在拼接。
例如:var i= from a in a where a.id1=null select a
var j= from b in b select b
var c=from temp in i
from tem in j
where temp.id=tem.id
selecr temp;
这样子应该可以满足你的要求了吧。
补充:.NET技术 , LINQ