I'm currently trying to write a class library for a connection to a database.  Looking over it, there are several different types of queries:  Select From, Update, Insert, etc.  My question is, what is the best practice for writing these queries in a C# application?  Should I have a separate method for each of them(i.e. Update(), Insert()), or have a generic Query() that would be able to handle all of these?  Thanks for any and all help!
Should I have a separate method for Update(), Insert(), etc., or have a generic Query() that would be able to handle all of these?
c#;database;methods;query
First, a bit about the lingo. Insert, update are not queries. A query in RDBMS is strictly a SELECT (Or a a sub-statement having WHERE clause). The set of verbs: SELECT, INSERT, UPDATE, DELETE are action statements in Data Manipulation Language (DML).Most answers so far revlove around how to achieve your objective, but your question is:Should I have a separate method for each of them(i.e. Update(), Insert()), or have a generic Query()The answer is yes. Each method should perform 1 function and return 1 type of result. You can re-use the connection logic or the ObjectContext (if you use Entity Framework) in each.Most of the code for handling the database would typically live in a separate tier or layer from your presentation logic.