使用 WCF 数据服务的不同数据库 [英] Different databases using WCF dataservice

查看:23
本文介绍了使用 WCF 数据服务的不同数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有多个具有相同架构的 SQL Server 数据库.我想使用一个 WCF 数据服务(Rest 服务)来访问不同的数据库.

I have multiple SQL Server databases with the same schema. I would like to use one WCF data service (Rest service) to access the different databases.

我怎样才能做到这一点,以便客户端可以传入正确的数据库名称或连接字符串?

How can I accomplish this so the client can pass in the correct database name or connection string?

推荐答案

你可以定义一些查询字符串参数,比如:

You could define some query string parameters, something like:

http://YourServer/YourService/SomeUrl?database=MyDatabase1

然后在您的服务器端代码中,使用该 database=MyDatabase1 来动态构建连接字符串,然后您可以使用该字符串打开与数据库的连接.应该不会太难,我想!

and then in your server-side code, use that database=MyDatabase1 to dynamically build the connection string, that you then use to open a connection to the database. Shouldn't be too hard, I think!

这篇关于使用 WCF 数据服务的不同数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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