Xaisoft
Xaisoft

Reputation: 46591

Using inline mysql in asp.net mvc?

I have an MVC app that has inline SQL all over the place. I am currently using MySQL and was curious if it would be a good idea to move the inline sql into functions or routines. This way, if it needed to be changed, I would just have to change the routine or function at the database level instead of at the code level which would require a new build. Is there an alternative approach?

Upvotes: 0

Views: 156

Answers (1)

vinodpthmn
vinodpthmn

Reputation: 1062

It is better to keep your sql statements out of c# code. There are couple of advantages,

  1. As you mentioned, you don't need a build everytime you change any sql code
  2. You will get slight performance improvisation
  3. More maintainability and readability

Also you could try EntityFramework as an alternate, where you don't need to bother about sql statements

Upvotes: 1

Related Questions