예제 #1
0
        public virtual IEnumerable <TEntity> GetWhere(object filters, int pageNumber, int pageSize)
        {
            var sql = SqlSelectGenerator.GetSelect(filters, pageSize, pageNumber);

            using (var connection = DbConnectionFactory.CreateConnection())
            {
                return(connection.Query <TEntity>(sql, filters));
            }
        }
예제 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="filters"></param>
        /// <returns></returns>
        public virtual IEnumerable <TEntity> GetWhere(object filters)
        {
            var sql = SqlSelectGenerator.GetSelect(filters);

            using (var connection = DbConnectionFactory.CreateConnection())
            {
                connection.Open();
                return(connection.Query <TEntity>(sql, filters));
            }
        }
예제 #3
0
        public virtual async Task <IEnumerable <TEntity> > GetWhereAsync(object filters, int pageNumber, int pageSize)
        {
            var sql = SqlSelectGenerator.GetSelect(filters, pageSize, pageNumber);

            using (var connection = DbConnectionFactory.CreateConnection())
            {
                connection.Open();
                return(await connection.QueryAsync <TEntity>(sql, filters));
            }
        }
예제 #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="filters"></param>
        /// <returns></returns>
        public virtual async Task <TEntity> GetFirstAsync(object filters)
        {
            var sql = SqlSelectGenerator.GetSelect(filters);

            using (var connection = DbConnectionFactory.CreateConnection())
            {
                connection.Open();
                Task <IEnumerable <TEntity> > queryTask = connection.QueryAsync <TEntity>(sql, filters);
                IEnumerable <TEntity>         data      = await queryTask;
                return(data.FirstOrDefault());
            }
        }