DbOperator db = new DbOperator("connectionString"); string query = "SELECT * FROM Customers WHERE City = @City"; SqlParameter[] parameters = { new SqlParameter("@City", "London") }; DataTable result = db.Select(query, parameters);
DbOperator db = new DbOperator("connectionString"); string query = "INSERT INTO Customers (CustomerName, ContactName, Country) VALUES (@CustomerName, @ContactName, @Country)"; SqlParameter[] parameters = { new SqlParameter("@CustomerName", "Alfreds Futterkiste"), new SqlParameter("@ContactName", "Maria Anders"), new SqlParameter("@Country", "Germany") }; int rowsAffected = db.Insert(query, parameters);
DbOperator db = new DbOperator("connectionString"); string query = "UPDATE Customers SET ContactName = @NewContactName WHERE CustomerID = @CustomerID"; SqlParameter[] parameters = { new SqlParameter("@NewContactName", "Peter Hansen"), new SqlParameter("@CustomerID", "ALFKI") }; int rowsAffected = db.Update(query, parameters);
DbOperator db = new DbOperator("connectionString"); string query = "DELETE FROM Customers WHERE CustomerID = @CustomerID"; SqlParameter[] parameters = { new SqlParameter("@CustomerID", "ALFKI") }; int rowsAffected = db.Delete(query, parameters);This example shows how to execute a DELETE query with a parameterized value and retrieve the number of rows affected. DbOperator is a package library that can be found and installed from the NuGet package manager.