C# Database Communication – Techniques for SQL

cdatabasesql

A few days ago, I read an answer stating that writing queries within your c# code are long gone.

I'm not sure what the specific person meant with the comment but, it got me thinking. At the company where i work, we maintain an assembly containing all the queries to the database (let's call it Queries). This assembly is reference by a QueryService (Retrieve the correct queries) assembly which in turn is referenced by a UnitOfWork assembly (The database connector classes, we have different connector classes for SQL, MySQL etc.). We use these three assemblies to perform operations on our database and all queries/commands are written by C# code.

Is there a better way to communicate with the database and is there a better way to communicate with different database types?

Best Answer

ORMs only work with simple database structures. For the most part I guess this is OK. If like me you need to get more out of your database than just select/update etc then I have found ORMs are not a good fit and will make your code longer, less clear, more difficult to manage...

Also SQL scripts and sprocs are essentially database language and we should not be scared to mix languages when they are the best fit for the job at hand

Related Topic