<div class=ForumPostBodyArea> <div class=ForumPostContentText>Hello,
I have a question regarding LINQ and/or ADO.NET Entity Framework. I need
to create a data service to provide CRUD
for ASP.NET Ajax and/or Silverlight clients.The
usual procedure for doing this follows the same general pattern in all of the training materials I have found: </div> <div class=ForumPostContentText> </div>
<div class=ForumPostContentText>
Create a model for the underlying data source, for example “Northwind.edmx”. This uses a connection specified in the VS 2008 IDE
at design time.
Create a LINQ or ADO.NET data service class in a server web application, which points to the model and provides the service endpoint
invoked by clients to select/insert/update/delete using a URI-based calling syntax, example of the data service would be “Northwind.svc”.
</div>I need to do the following:Create
a model in the usual way, but at run time I need a way to pass a parameter from the client to the “Northwind.svc” URI endpoint to specify the database name to be used when connecting to the underlying SQL server. I have a case where each client gets a unique
copy of a database schema (identical DDL script for every copy of the database), BUT each client instance contains the data which is unique to that client. It is not practical to create a model/service (.edmx/.svc) pair for every client individually, but I
can’t find any examples showing how to switch the database at run time. Is it possible to add parameters to the “Northwind.svc” URI beyond those used for data access? If so, how do I then pull out the parameter on the server side code and use it to change
the underlying connection string? Is there another/better/preferred way to modify the connection which is exposed by the data service?Can anyone
provide a code example (ideally using ADO.NET Entity Framework model and LINQ for data access class)? The client will be either ASP.NET or Silverlight.
None
0 Points
2 Posts
Change Data Service Connection at Runtime
Apr 02, 2009 09:33 AM|bigdatatech|LINK
Thank you!
</div>None
0 Points
2 Posts
Re: Change Data Service Connection at Runtime
Apr 16, 2009 04:39 PM|jerrybeers|LINK
Member
636 Points
373 Posts
Re: Change Data Service Connection at Runtime
Apr 21, 2009 04:45 AM|MisterFantastic|LINK
Hi There,
You can change the provider string details during the runtime to change to another db connection string.
http://msdn.microsoft.com/en-us/library/cc716756.aspx
or i think you can initialize the instance with the connectionstring details during the runtime.
ex
Dim d as Customer=new Customer("New Conn String details")
Thanks,
Thani