VB.NET LINQ加盟 [英] VB.NET LINQ join

查看:125
本文介绍了VB.NET LINQ加盟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在VB.NET LINQ这一具有挑战性的任务。
我从不同的服务器2的数据库。我不能链接数据库。该数据被从数据库中检索为:

I have this challenging task in VB.NET LINQ. I have 2 databases from different servers. I cannot link the databases. The data is retrieved from the databases as :


  • DB1

CLIENT_ID Engagement_ID说明已启用

在前端,我需要补充的是在DB1 present,而不是在DB2 present该客户的约会。我做和API调用来添加订婚,因为我无法更新数据库。
在这个例子中,我需要DB1的第二个记录添加到DB2作为客户端ID 600存在于DB2和客户端ID 600订婚ID 20 DB2不存在。我不能添加DB1的第三个记录到DB2作为客户端ID 700不存在DB2。
我需要的LINQ查询返回的记录,其中DB1.client_id = DB2.Client_ID和DB1.Engagement_ID<> DB2.Engagement_ID。如果LINQ查询数据表中的或某些数据结构返回记录,我可以通过记录循环,使API调用和传递客户端ID,参与ID,启用和描述作为参数来更新DB2。
请帮我这个问题。我试图这样做,但LINQ允许等值连接,我不能让它为DB1.client_id = DB2.Client_ID和DB1.Engagement_ID&LT工作;> DB2.Engagement_ID

In the front end I need to add the Engagements of the Clients that are present in DB1 and not present in DB2. I make and API call to add the engagements as I cannot update the database. In this example I need to add the second record of DB1 to DB2 as the client ID 600 exists in DB2 and the engagement ID 20 for Client ID 600 does not exist in DB2. I cannot add the third record of DB1 to DB2 as the client ID 700 does not exists in DB2. I need the LINQ query to return records where DB1.client_id = DB2.Client_ID and DB1.Engagement_ID <> DB2.Engagement_ID. If the LINQ query returns the records in a datatable or some data structure, I can loop through the records and make api calls and pass the client ID, engagement ID , Enabled and description as parameters to update DB2. Please help me with this issue. I tried to do it but LINQ allows equijoins and I cannot get it to work for DB1.client_id = DB2.Client_ID and DB1.Engagement_ID <> DB2.Engagement_ID.

的T SQL这个任务是:

THe T SQL for this task is:

select * from DB1
left join DB2 on DB1.client_ID = DB2.client_ID
and DB1.Engagement_ID = DB2.Engagement_ID
where DB2.CLient_ID is null and DB2.Engagement_ID is null
and DB1.client_id in (select client_id from DB2)

我想这件T SQL转换为LINQ

I am trying to convert this T SQL to LINQ

在此先感谢

推荐答案

您可以添加第二个连接标准为其中,子句:

You can add the second join criterion as a Where clause:

Dim q = From e1 In db1
        Join e2 In db2 On e1.Client_ID Equals e2.Client_ID
        Where e1.Engagement_ID <> e2.Engagement_ID
        Select e1, e2

这篇关于VB.NET LINQ加盟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆