I having a slight design problem : I have to create a Web Service (asmx or wcf) that retrieves customer data from multiple database servers, each one is exactly the same except they will contain data for different States (1 DB server per state, big states can have multiples etc).
This will be used by a call center, for example, someone calls the call center and says, can i have an indication when my order will be delivered my order no is "aa_etc" and the service should run a query on all servers and return all the orders details for that order.
This is straight forward, except there is multiple servers to query.My idea is to have central sqlite db with all connection strings of the current online servers and then query each one in turn
public class OnlineServer
{
public string Name {get;set;}
public string ConnectionString {get;set;}
}
...
public class Order
{
public List OrderDetail getDetails(string orderno,string connstring)
{
//Code to get all orders from database using specified connstring
}
....
}
....
List servers = getOnlineServers();
foreach(OnlineServer in servers)
{
OrderDetails d = Order.getDetails("aa_etc",OnlineServer.ConnectionString);
}
Just writing down this idea feels totally wrong.
I would really appreciate it if someone can help me get going with this in the right direction, this is a really big project and starting this wrong will just end up in tears later on.
Thanks
If you cannot some how merge the data in to a single DB. You may be able to use nHibernate. It can query multiple databases see http://mikehadlow.blogspot.com/2008/10/mapping-entities-to-multiple-databases.html
You would have to set up a different entity per server. By doing it this way it would take care of all your DB connections, pooling, sessions etc.
I want to consider this problem a bit futher but I have an off-the-wall idea which might be of interest so I'll through it out there.
My idea is to have central sqlite db with all connection strings of the current online servers and then query each one in turn
This gave me an idea: why not fire off a search query to each system asynchonously? I'm thinking AJAX here (but you could use iFrames)...
I'm assuming the data would be "pulled together" visually by the UI - either by straight layout or via clever client-side code - this would give you further options to tailor the UI but at the expense of a more complex client-side code base.
You'd have other options too, like allowing the user to narrow their search by data source if they wanted to.
Also, adding / removing data sources would be simple.
This is where I need to address you're actual question more directly; in my opinion you'd most definately want a seperate service per database - but there's flexibility in how you do that.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.