void ThrowIfInvalid(DemographicQueryRecord record) { if (record == null) { throw new InvalidOperationException("The app.DemographicQuery record is missing"); } if (string.IsNullOrWhiteSpace(record.SqlStatement)) { throw new InvalidOperationException("app.DemographicQuery.SqlStatement is empty"); } }
public async Task <DemographicQuery> UpdateDemographicQueryAsync(DemographicQuery query) { log.LogInformation("Updating DemographicQuery SqlStatement:{SqlStatement}", query.SqlStatement); var record = new DemographicQueryRecord(query); ThrowIfInvalid(record); using (var cn = new SqlConnection(opts.ConnectionString)) { await cn.OpenAsync(); await cn.ExecuteAsync( queryUpdate, new { sql = record.SqlStatement, user = user.UUID }, commandTimeout : opts.DefaultTimeout, commandType : CommandType.StoredProcedure ); return(query); } }