Esempio n. 1
0
        /// <summary>
        /// Creates a command which will get all the entities
        /// </summary>
        public static CommandDefinition MakeGetAllCommand <TEntity>(
            IDbTransaction transaction,
            IDialect dialect,
            int?commandTimeout,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            var config = MicroCRUDConfig.Current;

            dialect = dialect ?? config.Dialect;

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

            return(MakeCommandDefinition(sql, null, transaction, commandTimeout, cancellationToken));
        }
Esempio n. 2
0
        /// <summary>
        /// Creates a command which will get all the entities matching the <paramref name="conditions"/>.
        /// </summary>
        public static CommandDefinition MakeGetRangeCommand <TEntity>(
            object conditions,
            IDbTransaction transaction,
            IDialect dialect,
            int?commandTimeout,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            Ensure.NotNull(conditions, nameof(conditions));
            var config = MicroCRUDConfig.Current;

            dialect = dialect ?? config.Dialect;

            var entityType       = typeof(TEntity);
            var tableSchema      = TableSchemaFactory.GetTableSchema(entityType, dialect, config.SchemaFactory);
            var conditionsSchema = TableSchemaFactory.GetConditionsSchema(entityType, tableSchema, conditions.GetType(), dialect, config.SchemaFactory);
            var sql = dialect.MakeGetRangeStatement(tableSchema, dialect.MakeWhereClause(conditionsSchema, conditions));

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