c# Linq left join 多个条件连接查询
来源:学生作业帮 编辑:神马作文网作业帮 分类:综合作业 时间:2024/11/12 23:08:31
c# Linq left join 多个条件连接查询
如下面的sql 用查询表达式怎么写?
SELECT A.*,B.ITEM_NAME AS MoneyType_DESC,C.ITEM_NAME AS PayMentType_DESC,D.ITEM_NAME AS ApplyType_DESC
FROM DFZFORMT055 A
LEFT JOIN FM_CODE_LIST B ON A.MoneyType = B.ITEM_VALUE AND B.FORM_KIND = 'DFZ.FORM.T055' AND B.FIELD_NAME= 'MoneyType'
LEFT JOIN FM_CODE_LIST C ON A.PayMentType = C.ITEM_VALUE AND C.FORM_KIND = 'DFZ.FORM.T055' AND C.FIELD_NAME= 'PayMentType'
LEFT JOIN FM_CODE_LIST D ON A.APPLYTYPE = D.ITEM_VALUE AND D.FORM_KIND = 'DFZ.FORM.T055' AND D.FIELD_NAME= 'ApplyType'
WHERE A.form_no=9
自己搞定了,还是要谢谢 w362435819和 fansui1983
var query = from MainTable in T055
join B in (from codelist in CODELIST where codelist.FORM_KIND=="DFZ.FORM.T055" &&codelist.ITEM_NAME=="MoneyType" select codelist)
on MainTable.MoneyType equals B.ITEM_VALUE into B_Join
from BB in B_Join.DefaultIfEmpty()
join C in (from codelist in CODELIST2 where codelist.FORM_KIND == "DFZ.FORM.T055" && codelist.ITEM_NAME == "PayMentType" select codelist)
on MainTable.PayMentType equals C.ITEM_VALUE into C_Join
from CC in C_Join.DefaultIfEmpty()
join D in .
where MainTable.FORM_NO == m_intFormNo
如下面的sql 用查询表达式怎么写?
SELECT A.*,B.ITEM_NAME AS MoneyType_DESC,C.ITEM_NAME AS PayMentType_DESC,D.ITEM_NAME AS ApplyType_DESC
FROM DFZFORMT055 A
LEFT JOIN FM_CODE_LIST B ON A.MoneyType = B.ITEM_VALUE AND B.FORM_KIND = 'DFZ.FORM.T055' AND B.FIELD_NAME= 'MoneyType'
LEFT JOIN FM_CODE_LIST C ON A.PayMentType = C.ITEM_VALUE AND C.FORM_KIND = 'DFZ.FORM.T055' AND C.FIELD_NAME= 'PayMentType'
LEFT JOIN FM_CODE_LIST D ON A.APPLYTYPE = D.ITEM_VALUE AND D.FORM_KIND = 'DFZ.FORM.T055' AND D.FIELD_NAME= 'ApplyType'
WHERE A.form_no=9
自己搞定了,还是要谢谢 w362435819和 fansui1983
var query = from MainTable in T055
join B in (from codelist in CODELIST where codelist.FORM_KIND=="DFZ.FORM.T055" &&codelist.ITEM_NAME=="MoneyType" select codelist)
on MainTable.MoneyType equals B.ITEM_VALUE into B_Join
from BB in B_Join.DefaultIfEmpty()
join C in (from codelist in CODELIST2 where codelist.FORM_KIND == "DFZ.FORM.T055" && codelist.ITEM_NAME == "PayMentType" select codelist)
on MainTable.PayMentType equals C.ITEM_VALUE into C_Join
from CC in C_Join.DefaultIfEmpty()
join D in .
where MainTable.FORM_NO == m_intFormNo
from A in DFZFORMT055 join B in FM_CODE_LIST on
A.MoneyType = B.ITEM_VALUE AND B.FORM_KIND = 'DFZ.FORM.T055' AND B.FIELD_NAME= 'MoneyType'
join C in JOIN FM_CODE_LIST on
A.PayMentType = C.ITEM_VALUE AND C.FORM_KIND = 'DFZ.FORM.T055' AND C.FIELD_NAME= 'PayMentType'
join D in FM_CODE_LIST on
A.APPLYTYPE = D.ITEM_VALUE AND D.FORM_KIND = 'DFZ.FORM.T055' AND D.FIELD_NAME= 'ApplyType'
where A.form_no=9
select A
再问: 不行,报错。DFZFORMT055为主表,FM_CODE_LIST为下拉菜单的数据存储表,以FORM_KIND,FIELD_NAME两栏位确定是那一下拉菜单的数据,ITEM_NAME,ITEM_VALUE为下拉菜单的值和显示名。 请表栏位:MoneyType ,PayMentType ,APPLYTYPE 为存储拉菜单值,但不一定会存入,所以就用left join 查找主管中的数据及下拉菜单有储存值的数据名。写sql很简单实现,后来改成linq实现就绑手绑脚的,又找不到相关的资料,还请各位高手多多指点。
A.MoneyType = B.ITEM_VALUE AND B.FORM_KIND = 'DFZ.FORM.T055' AND B.FIELD_NAME= 'MoneyType'
join C in JOIN FM_CODE_LIST on
A.PayMentType = C.ITEM_VALUE AND C.FORM_KIND = 'DFZ.FORM.T055' AND C.FIELD_NAME= 'PayMentType'
join D in FM_CODE_LIST on
A.APPLYTYPE = D.ITEM_VALUE AND D.FORM_KIND = 'DFZ.FORM.T055' AND D.FIELD_NAME= 'ApplyType'
where A.form_no=9
select A
再问: 不行,报错。DFZFORMT055为主表,FM_CODE_LIST为下拉菜单的数据存储表,以FORM_KIND,FIELD_NAME两栏位确定是那一下拉菜单的数据,ITEM_NAME,ITEM_VALUE为下拉菜单的值和显示名。 请表栏位:MoneyType ,PayMentType ,APPLYTYPE 为存储拉菜单值,但不一定会存入,所以就用left join 查找主管中的数据及下拉菜单有储存值的数据名。写sql很简单实现,后来改成linq实现就绑手绑脚的,又找不到相关的资料,还请各位高手多多指点。
linq用lambda表达式 left join 自连接怎么写
怎样在LINQ实现 LEFT JOIN 或者RIGHT JOIN
sql表连接查询的区别`inner join、left join、rightjoin、outer join举例说明·
left join 和 right jion 怎么表示 LINQ
如何将linq left join 的写法转换成 limq left join lambad的写法
SQL 中left join连接多张表
SSH怎么使用外连接.right join,left join
right join/left join/full join这三种外连接主要用在什么条件下?
left join,right join 和 left out join,right out join 有什么区别吗?多
左连接和左外连接有什么区别即left join 和left outer join 有什么区别?
oracle中的left join 表名 on 条件1 and 条件2
C#高级编程的第十一章LINQ的295页有一个Lambda表达式看不懂,