I have a Windows Application in C#. This application interacts with a remote mySQL database. Should开发者_运维知识库 I create a PHP web service to do these (insert/add/delete/update) or use mySQL connector for c#? I'm not sure which way is better.
Thanks!
Wether the MySQL server is in the same network (phisically) or not. From my point of view the according solution would be to create a dedicated Web-Service that provides you the CRUD functionality for your application.
This, because it gives you some Separation of Concerns (SoC) as you can separate business logic tier from the data access tier.
See also: Single Responsibility Principle | "In object-oriented programming, the single responsibility principle states that every object should have a single responsibility, and that responsibility should be entirely encapsulated by the class. All its services should be narrowly aligned with that responsibility."
Every part of your application serves a specific purpose which makes it easier to maintain over a big timespan.
Now this sounds pretty nice and cool, but do we really need to abstract everything away?
As with everything else, it depends.
Here is a little Use-Case:
- The Database needs to be modified: Tables keys are removed, new tables are added old tables are removed.
What will you, as developer, need to do in order to keep your application working?
Using MySQLConnector: Start "hacking" inside your source code and making sure all queries run as expected. And if something goes wrong during that process, it will be a pain to fix it because it's all kind of nested within the application logic.
Using a dedicated Web-Service: Just make sure your methods are updated to match the new database design | No need to change anything on the application-side [except method arguments in some cases].
Cheers
Why use PHP web-service when the application is in c# ? just use the MySql connector for C#. Secondly web-service performance will be slow compared to MySql connector for C#.
精彩评论