Beispiel #1
0
        /// <summary>
        /// 获取
        /// </summary>
        /// <returns></returns>
        public T GetFirst()
        {
            SelectSqlHelper <T> Select = new SelectSqlHelper <T>();

            Select.SetTop(1);
            return(connection.Query <T>(Select.GetSql(this)).FirstOrDefault());
        }
Beispiel #2
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());
        }