public T ExecuteNonQuery <T>(IDataOperation <T> op) { using (var cn = new SqlConnection(this.connectionString)) { var cmd = op.ConstructCommand(cn); cn.Open(); int rc = cmd.ExecuteNonQuery(); T result = op.Return(cmd, rc); cn.Close(); return(result); } }
/// <summary> /// Asynchronously execute the given data operation expected to not return any values. /// </summary> /// <param name="op"></param> /// <param name="factory"></param> /// <returns></returns> public async Task <T> ExecuteNonQueryAsync <T>(IDataOperation <T> op, TaskFactory <T> factory = null) { if (factory == null) { factory = new TaskFactory <T>(); } using (var cn = new SqlConnection(this.connectionString)) { var cmd = op.ConstructCommand(cn); cn.Open(); int rc = await cmd.ExecuteNonQueryAsync(); T result = op.Return(cmd, rc); cn.Close(); return(result); } }