Ejemplo n.º 1
0
        /// <summary>
        /// Creates a command which will insert update an entity by using its primary key.
        /// </summary>
        public static CommandDefinition MakeUpdateCommand <TEntity>(
            object entity,
            IDbTransaction transaction,
            IDialect dialect,
            int?commandTimeout,
            MicroCRUDConfig config,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            Ensure.NotNull(entity, nameof(entity));
            dialect = dialect ?? config.Dialect;

            var tableSchema = TableSchemaFactory.GetTableSchema(typeof(TEntity), dialect, config.SchemaFactory);
            var sql         = dialect.MakeUpdateStatement(tableSchema);

            return(MakeCommandDefinition(sql, entity, transaction, commandTimeout, cancellationToken));
        }