C# 如何在SvcClient实体中调用内部联接?
调用webservice调用时如何插入连接实体C# 如何在SvcClient实体中调用内部联接?,c#,linq,web-services,C#,Linq,Web Services,调用webservice调用时如何插入连接实体 SELECT distinct [COMMITTEE_MAST_CUST] FROM [PDEV].[dbo].[COM_COMMITTEE_MEMBER] cc Inner join CUSTOMER c on c.MASTER_CUSTOMER_ID = cc.COMMITTEE_MAST_CUST where MEMBER_MAST_CUST = '0827857' and cc.END_DATE &g
SELECT
distinct [COMMITTEE_MAST_CUST]
FROM [PDEV].[dbo].[COM_COMMITTEE_MEMBER] cc Inner join CUSTOMER c
on c.MASTER_CUSTOMER_ID = cc.COMMITTEE_MAST_CUST
where MEMBER_MAST_CUST = '0827857' and cc.END_DATE > GETDATE()
and c.CUSTOMER_CLASS_CODE IN ('SECTION_OFFICER','CHAPTER_OFFICER')
但是现在使用上面的查询,我们不知道在这个查询中应该把join放在哪里
SvcClient.Client.Context.ComCommittees.Where(x => x.MemberMasterCustomer
== masterCustomerId && x.EndDate > DateTime.Today.AddMonths(-3)).ToList();
我不确定您的上下文是如何定义的(SvcClient.Client.Context.comcomcommittees是否对应于[PDEV].[dbo].[COM_COMMITTEE_MEMBER]?),但我相信您会将.Join放在.Where子句之前 大概是这样的:
SvcClient.Client.Context.ComCommittees.Join(Customer, mast => id.COMMITTEE_MAST_CUST, cust=>cust.MASTER_CUSTOMER_ID, (mast, cust) => new { cc = mast, c = cust }).Where(x => x.MemberMasterCustomer
== masterCustomerId && x.EndDate > DateTime.Today.AddMonths(-3)).ToList();
虽然应该考虑在查询语法中写:
var myResult = (from cc in SvcClient.Client.Context.ComCommittees
join customer in CustomerContext on cc.COMMITTEE_MAST_CUST equals customer.MASTER_CUSTOMER_ID
where (cc.MemberMasterCustomer == masterCustomerId) && (cc.EndDate > DateTime.Today.AddMonths(-3))).ToList()
(我不确定您的一些变量名称,但这是基本jist)中的c.CUSTOMER\u CLASS\u代码('SECTION\u OFFICER','CHAPTER\u OFFICER')&&[“SECTION\u OFFICER”,“CHAPTER\u OFFICER”]包含(CUSTOMER.CUSTOMER\u CLASS\u代码)如何