public void BuildUpdate_WithSchema() { var tableMD = GetTestMetadata(); tableMD.Schema = "testschema"; var sql = TSQLGenerator.BuildUpdate(tableMD); Assert.AreEqual("UPDATE [testschema].[testtable] SET [b]=@bb,[c]=@cc WHERE [a]=@aa", sql); }
public static bool Update <T>(this IDbConnection connection, T entityToUpdate, IDbTransaction transaction = null, int?commandTimeout = null) where T : class { var type = typeof(T); var metadata = MetadataFor(type); string sql; if (!s_updateQueries.TryGetValue(type.TypeHandle, out sql)) { s_updateQueries[type.TypeHandle] = sql = TSQLGenerator.BuildUpdate(metadata); } Log(sql, entityToUpdate); var updated = connection.Execute(sql, entityToUpdate, commandTimeout: commandTimeout, transaction: transaction); return(updated > 0); }