c# - Entity Framework Execute Query on Multiple Servers -


i developing first c# web app , needs import data multiple servers on demand.

i have server names stored in table (dataserver). need connect each server , run query, results of want add data model.

this have in repository

public void scanserver(int serverkey)     {         var servername =  findbykey(serverkey).servername;         var sqlquery = "select name ,description mytbl";          context.database.sqlquery<names>(sqlquery);     } 

i know using context incorrect, i'm hoping replace connection string held in dataserver table.

the results need added names datamodel.

am on right track this?

you should able open connection using connection string thus:

foreach(string connectionstring in servers) {     using (var context = new dbcontext(connectionstring))     {       //query code     } } 

Comments

Popular posts from this blog

matlab - error with cyclic autocorrelation function -

django - (fields.E300) Field defines a relation with model 'AbstractEmailUser' which is either not installed, or is abstract -

c# - What is a good .Net RefEdit control to use with ExcelDna? -