专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > LINQ

帮忙看看这个如何成LINQ

发布时间:2011-06-24 21:54:11 文章来源:www.iduyao.cn 采编人员:星星草
帮忙看看这个怎么成LINQ?
select 
count(a.fund_id) n
from 
t_fund_info as a
inner join t_fund_join_year as b
on a.fund_id = b.fund_id
inner join t_fund_type as c 
on b.type = c.type_id
where a.status in(1,2) and 
b.category = 19 and
c.type_id in (24,25) and 
b.join_year = 0 and 
b.status = 1  
and exists(
select * from t_fund_org_index as i
where  
i.org_type in(100043) 
and a.fund_id = i.fund_id
and (i.is_current = 1 OR a.status = 2)
and exists(
select * from t_org_class as os
where os.class_type in (100053) and os.org_id = i.org_id
)
)

对linq语法不是很懂。请大家帮帮忙

------解决方案--------------------
不懂 帮顶
------解决方案--------------------
select
ti.fund_id,
ti.fund_name,
dbo.fun_get_org_mebmer(fund_id,1),
dbo.fun_get_org_info(fund_id,100050) 
from
t_fund_info as a
inner join t_fund_join_year as b
on a.fund_id = b.fund_id
inner join t_fund_type as c
on b.type = c.type_id
where a.status in(1,2) and
b.category = 19 and
c.type_id in (24,25) and
b.join_year = 0 and
b.status = 1
and exists(
select * from t_fund_org_index as i
where
i.org_type in(100043)
and a.fund_id = i.fund_id
and (i.is_current = 1 OR a.status = 2)
and exists(
select * from t_org_class as os
where os.class_type in (100053) and os.org_id = i.org_id

)

其实sql的原型是这个
------解决方案--------------------
var query =(from a in db.t_fund_info
join b in db.t_fund_join_year on a.fund_id equals b.fund_id
join c in db.t_fund_type on b.type equals c.type_id
where 
(
new int[]{1,2}
).Contains(a.status) && (b.category == 19) &&
(
new int[]{24,25}
).Contains(c.type_id) && (b.join_year == 0) &&(b.status == 1) &&
(db.t_fund_org_index.Any(c=>(c.org_type==100043)&&(a.fund_id = c.fund_id)&&(c.is_current == 1 || a.status == 2)&&(db.t_org_class.Any(d=>d.class_type==100053&&d.org_id==c.org_id)))
select a.fund_id).Count();

再试试这个,我都试过了,没有错误
顺便提下,你的这个也太长了
就不能分开来写吗
搞的这么长……
------解决方案--------------------
C# code


var query=(from a in db.t_fund_info 
          join b in db.t_fund_join_year
          on a.fund_id equals b.fund_id
          join c in db.t_fund_type
          on b.type equals c.type_id
          let temp= from i in db.t_fund_org_index
                    let t=db.t_org_class.Where(os=>new int[]{100053}.Contains(os.class_type)
                                              && os.org_id ==i.org_id)
                    where new int[]{100043}.Contains(i.org_type)
                    && a.fund_id == i.fund_id
                    && (i.is_current==1 || a.status==2)
                    && t.Any()
                    select i   //sorry for this place
          where new int[]{1,2}.Contains(a.status)
             &&new int[]{24,25}.Contains(c.type_id)
             && b.category==19 && b.join_year==0 && b.status==1
             && temp.Any()
          select a.fund_id).Count();
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: