简体   繁体   English

实体框架+ SQL CLR +远程数据库

[英]Entity Framework + SQL CLR + remote database

I have a project in which I use WCF Data Services to expose access to certain tables in my database (db1). 我有一个项目,在其中我使用WCF数据服务公开对数据库(db1)中某些表的访问。

now, the requirements just changed and I am required to fetch data that used to be from database db1, table teacher from a new database db2, table teacher2, but to keep everything else same. 现在,需求刚刚发生变化,我需要从新数据库db2,表Teacher2中获取以前从数据库db1和表Teacher中获取的数据,但要使其他所有内容保持不变。

I am thinking of doing the following : 我正在考虑做以下事情:

1- set up the .edmx file of the service to point to a stored procedure (SQL CLR), instead of pointing to table teacher. 1-将服务的.edmx文件设置为指向存储过程(SQL CLR),而不是指向表教师。

2- in SQL CLR, initiate the connection using proprietary API and connect to database db2, and retrieve data from there. 2-在SQL CLR中,使用专有API发起连接并连接到数据库db2,然后从那里检索数据。

3- send the data retrieved from db2 back to the WCF Data Services client. 3-将从db2检索到的数据发送回WCF数据服务客户端。

Is this possible ? 这可能吗 ? If so, How to do it ? 如果是这样,该怎么做? Is there a better way to achieve the same ? 有没有更好的方法可以达到相同目的?

You can have more than one edmx per project, and more than one wcf data service. 每个项目可以有一个以上的edmx,以及一个以上的wcf数据服务。 I would make a second one. 我会再讲第二个。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM