我的应用程序中有2个数据上下文(不同的数据库),需要能够在上下文中查询上下文A中的表,并在上下文中的表上使用右连接.如何在LINQ2SQL中执行此操作?Why?: We are using a SaaS product for tracking our time, projec...

我的应用程序中有2个数据上下文(不同的数据库),需要能够在上下文中查询上下文A中的表,并在上下文中的表上使用右连接.如何在LINQ2SQL中执行此操作?
Why?: We are using a SaaS product for tracking our time, projects, etc. and would like to send new service requests to this product to prevent our team from duplicating data entry.
Context A: This db stores service request information. It is a third party DB and we are not able to make changes to the structure of this DB as it could have unintended non-supportable consequences downstream.
Context B: This data stores the “log” data of service requests that have been processed. My team and I have full control over this DB’s structure, etc. Unprocessed service requests should find their way into this DB and another process will identify it as not being processed and send the record to the SaaS product.
这是我想要修改的查询.我最初能够做一个!list.Contains(c.swHDCaseId),但这不能处理超过2100个项目.有没有办法将连接添加到其他上下文?
var query = (from c in contextA.Cases
where monitoredInboxList.Contains(c.INBOXES.inboxName)
//right join d in contextB.CaseLog on d.ID = c.ID....
select new
{
//setup fields here...
});
解决方法:
在数据库解决方案之外,最好的办法是在执行后使用LINQ(对象)进行连接.
我意识到这不是你所希望的解决方案.至少在这个级别,你不必担心IN列表限制(.Contains)
编辑:
在上面的数据库解决方案之外真正指向链接服务器解决方案,其中允许来自上下文A的表/视图从上下文B存在于数据库中.
本文标题为:c# – 如何使用LINQ2SQL连接两个不同上下文的表?


基础教程推荐
- c# – 在Windows Phone 8.1中处理UI性能问题的最佳方法 2023-09-18
- 基于C#实现语音识别功能详解 2023-06-04
- C#写的windows应用程序打包 2023-09-19
- c# – 业务层设计困境:内存还是IO? 2023-09-19
- C# 中 “$” 符号的作用以及用法详解 2023-02-25
- C#将PDF转为多种图像文件格式的方法(Png/Bmp/Emf/Tiff) 2022-12-09
- C# 数独求解算法的实现 2023-02-06
- dotnet core 在CentOS下 使用libreoffice 把Office 转换成pdf 2023-09-26
- C# 命名空间(Namespace)相关知识总结 2023-03-03
- 如何用WindowsForm给窗口添加一些简单的动画效果 2023-03-03