下面的sql用linq怎么写?求解
selectt.opinion,t.node,t.result,d.flow_state,t.data_id,count(t.create_user)fromOMT_DE...
select t.opinion,t.node,t.result,d.flow_state,t.data_id, count(t.create_user)
from OMT_DEFECT_FLOW t inner join OMT_DEFECT_DETAIL d on d.id=t.data_id
group by d.flow_state,t.opinion,t.node,t.result,t.data_id having t.data_id='4c51493f-0751-4614-a462-35ed6ec169d0'
and d.flow_state='S030' 展开
from OMT_DEFECT_FLOW t inner join OMT_DEFECT_DETAIL d on d.id=t.data_id
group by d.flow_state,t.opinion,t.node,t.result,t.data_id having t.data_id='4c51493f-0751-4614-a462-35ed6ec169d0'
and d.flow_state='S030' 展开
展开全部
// 试试这个group by 多列形式的LINQ
var query=from t in dbo.OMT_DEFECT_FLOW
from d in dbo.OMT_DEFECT_DETAIL
group t,d by new{ // new一个匿名类
t.opinion,
t.node,
t.result,
d.flow_state,
t.data_id,
count=dbo.OMT_DEFECT_FLOW.Count(p=>create_user)
}
into g
select new{
g.key, // 这里的key就是上面new的匿名类的对象,其属性为上述的属性
g
};
// 在foreah取值时在加上一个判断 如:
foreach(var _query in query){
foreach(var item in _query.g)
if(item.flow_state=="S030"){
// To do sth...
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询