private long ExecuteDMLQuery(T entity, ToSqlCommand commandDelegate) { using (SqlConnection connection = new SqlConnection(CONNECTION_STRING)) { connection.Open(); using (IDbCommand command = commandDelegate(entity, connection)) { return(Convert.ToInt64(command.ExecuteScalar())); } } }
private long ExecuteDMLQuery(T entity, ToSqlCommand commandDelegate) { using (SqlConnection connection = new SqlConnection(CONNECTION_STRING)) { connection.Open(); using (IDbCommand command = commandDelegate(entity, connection)) { object result = command.ExecuteScalar(); return(result != null?Convert.ToInt64(result) : -1); } } }