public override IEnumerable <UserDisplayData> Execute()
        {
            IEnumerable <UserDisplayData> accounts = null;

            string query = BASE_QUERY;

            SqlFilterCriterion criterion = (SqlFilterCriterion)Filter;

            bool usesParameter = criterion.UsesParameter;

            DbParameter[] parameters = null;

            if (criterion != null)
            {
                query += $"WHERE {criterion.Evaluate()} ";

                parameters = criterion.GetParameters();
            }

            if (Ordering != null)
            {
                query += string.Format("ORDER BY {0} ", Ordering.Evaluate());
            }

            MySQLProvider provider = new MySQLProvider(DBConfiguration.ConnectionString);
            SQLCaller     caller   = new SQLCaller(provider);

            DbCommand command = criterion.UsesParameter ? provider.CreateCommand(query, parameters) : provider.CreateCommand(query);

            accounts = caller.Get(MapUserDisplay, command);

            return(accounts);
        }
Пример #2
0
            public override DbParameter[] GetParameters()
            {
                DbParameter parameter = new MySQLProvider().CreateInputParameter("@" + GENDER_COLUMN, (int)Gender);

                parameter.DbType = DbType.Byte;
                return(new DbParameter[] { parameter });
            }