public void CreateRecordInDatabase(DbRecord dbRecord) { string createQuery = BuildCreateString(dbRecord); var sqlParameters = dbRecord.Values.Select(t => new SqlParameter("@" + t.Key, t.Value)).ToArray(); using (var sqlWrapper = new MssqlWrapper(connection.GetConnection() as SqlConnection)) { sqlWrapper.ExecuteNonQuery(createQuery, sqlParameters); } }
public void UpdateRecordInDatabase(DbRecord dbRecord) { string updateQuery = BuildUpdateString(dbRecord); var sqlColumnParameters = dbRecord.Values.Select(t => new SqlParameter("@" + t.Key, t.Value)).ToArray(); var sqlWhereParameters = dbRecord.Identifiers.Select(t => new SqlParameter("@whereparam_" + t.Key, t.Value)).ToArray(); using (var sqlWrapper = new MssqlWrapper(connection.GetConnection() as SqlConnection)) { sqlWrapper.ExecuteNonQuery(updateQuery, sqlColumnParameters.Concat(sqlWhereParameters).ToArray()); } }