Question

We are migrating from an ASP.NET/SQL server setup to a rails/mysql setup. Because of this, I need to transfer the data out of my SQL Server database, but I can't directly move it from SQL Server to mysql because there are some things which need to be done on a per-record basis by rails in a filter.

Due to the way this process needs to be handled, I think the best way would be for my rails web server to consume a web service from the ASP.NET server and have it pull the records from the SQL Server database. After the rails server modifies the data, it can then save each record in the database.

I want to return a simple "select * from table_name" query which is determined by the rails server. In short, I want the rails server to send "select * from customers" to the ASP.NET server, then the asp.net server return the list of data via XML or json.

Is this possible? I know it's possible to return data via a web service, but I am wondering if if the sql query can be determined on the consuming server.

Thank you!

Was it helpful?

Solution

You should check the WCF Data Services and ADO.NET Data Services
I think it fits your needs.

For table Customers query to your DataService will be http://localhost:12345/DATABASE_NAME.svc/Customers, and you can easily add some filter expressions to your query.

OTHER TIPS

ServiceStack also makes this dead easy to do where with just 1 Line of Code your web services can automatically return data in XML, JSON, CSV, JSV and even HTML for an easy to read tabular view of your data.

View the Northwind data example where the following code is all you need to return a List of Customer POCOs:

    public class CustomersService : RestServiceBase<Customers>
    {
            public IDbConnectionFactory DbFactory { get; set; }

            public override object OnGet(Customers request)
            {
              return new CustomersResponse { Customers = DbFactory.Exec(dbCmd =>
                    dbCmd.Select<Customer>()) 
            };
    }

Then with just the code above you can call the webservice returning all of:

I wouldn't go for Web Services at all.

You can export data from SQL-SERVER in .cvs (Flat File Destination) format and then parse it from RoR. I have no idea how to do so but obviously RoR has .cvs IO tools built-in in framework.

If you have large amount of data using web service will be much less efficient than creating .cvs file and consuming it locally for inserts.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top