Exemplo n.º 1
0
        public static DataTable ReadListTable(Type entityType, string[] fields, Condition[] parameters, string[] orders, int limitNumberOfEntities)
        {
            PersistenceStrategy strategy;
            string tableName, sql, paramPrefix, paramSuffix;

            string[]  filterFields, filterParams;
            object[]  parameterValues;
            DataTable table;

            Operator[] operators;

            strategy        = PersistenceStrategyProvider.FindStrategyFor(entityType);
            tableName       = strategy.GetTableNameOf(entityType);
            filterFields    = StrHelper.GetPropertyValuesOf(parameters, "Field");
            filterParams    = StrHelper.GetNumbers(0, filterFields.Length);
            parameterValues = ArrayHelper.GetPropertyValuesOf(parameters, "Value");
            operators       = ArrayHelper.GetPropertyValuesOf <Operator>(parameters, "Operator");

            paramPrefix  = Transaction.SqlHelper().ParameterPrefix();
            paramSuffix  = Transaction.SqlHelper().ParameterSuffix();
            filterParams = StrHelper.Concat(paramPrefix, filterParams, paramSuffix);

            sql = Transaction.SqlHelper().BuildSelectSqlFor(tableName, fields, filterFields, operators, filterParams, orders, limitNumberOfEntities);

            table = Transaction.Instance.ExecuteSql(sql, parameterValues);

            return(table);
        }