Exemplo n.º 1
0
        /// <summary>
        /// 查询条件获取所有
        /// </summary>
        /// <returns></returns>
        public List <T> GetList(Expression <Func <T, bool> > where)
        {
            SelectSqlHelper <T> Select = new SelectSqlHelper <T>();

            Select.SetWhere(where);
            return(connection.Query <T>(Select.GetSql(this)).ToList());
        }
Exemplo n.º 2
0
        /// <summary>
        /// 查询条件获取所有
        /// </summary>
        /// <returns></returns>
        public List <T> GetList(Expression <Func <T, bool> > where, Expression <Func <T, object> > OrderBy, bool IsDesc = true)
        {
            SelectSqlHelper <T> Select = new SelectSqlHelper <T>();

            Select.SetWhere(where);
            Select.SetSorting(OrderBy, IsDesc);
            return(connection.Query <T>(Select.GetSql(this)).ToList());
        }
Exemplo n.º 3
0
        /// <summary>
        /// 查询条件获取第一个
        /// </summary>
        /// <param name="where"></param>
        /// <returns></returns>
        public T GetFirst(Expression <Func <T, bool> > where)
        {
            SelectSqlHelper <T> Select = new SelectSqlHelper <T>();

            Select.SetTop(1);
            Select.SetWhere(where);
            return(connection.Query <T>(Select.GetSql(this)).FirstOrDefault());
        }