我的应用程序中有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连接两个不同上下文的表?
- windows下asp.net core 低成本最简化部署方式 2023-09-26
- 从Request.Url中获取根网址的简单操作 2023-03-29
- C#调用带结构体指针Dll的方法 2023-04-27
- C#调用webservice接口的最新方法教程 2022-11-19
- C#中互操作性简介 2023-03-09
- C#中字符串优化String.Intern、IsInterned详解 2022-11-24
- Unity实现画线条功能 2023-01-16
- C#基于Mongo的官方驱动手撸一个Super简易版MongoDB-ORM框架 2023-04-15
- C#托管内存与非托管内存之间的转换的实例讲解 2023-01-28
- 3种C# 加载Word的方法 2023-05-05