예제 #1
0
        public SqlLam <T2> Join <T2>(Expression <Func <T, T2, bool> > expression)
        {
            var joinQuery = new SqlLam <T2>(_builder, _resolver);

            _resolver.Join(expression);
            return(joinQuery);
        }
예제 #2
0
        public IEnumerable <TEntity> GetPagingList(Pagination p, Expression <Func <TEntity, bool> > expression, Expression <Func <TEntity, object> > orderBy)
        {
            var sql = this.GetSqlLam().Where(expression).OrderBy(orderBy);
            // TODO: (已实现) 修复用户管理列表查询出错 - Roc Qing
            //var sqlCount = new SqlLam<TEntity>().Where(expression);
            var sqlCount = new SqlLam <TEntity>().Where(expression).Count();

            return(this.GetPagingList(p, sql, sqlCount));
        }
예제 #3
0
        public IEnumerable <TEntity> GetPagingList(Pagination p, SqlLam <TEntity> sql, SqlLam <TEntity> sqlCount)
        {
            string sqlText = sql.QueryPage(p.rows, p.page) + @";" + sqlCount.SqlString;
            var    reader  = connection.QueryMultiple(sqlText, sql.Parameters);
            var    list    = reader.Read <TEntity>();
            var    records = reader.Read <int>().FirstOrDefault();

            p.records = records;
            return(list);
        }
예제 #4
0
        public SqlLam <TResult> Join <T2, TKey, TResult>(SqlLam <T2> joinQuery,
                                                         Expression <Func <T, TKey> > primaryKeySelector,
                                                         Expression <Func <T, TKey> > foreignKeySelector,
                                                         Func <T, T2, TResult> selection)
        {
            var query = new SqlLam <TResult>(_builder, _resolver);

            _resolver.Join <T, T2, TKey>(primaryKeySelector, foreignKeySelector);
            return(query);
        }
예제 #5
0
        public SqlLam <TEntity> GetSqlLam()
        {
            string           key   = typeof(TEntity).FullName;
            ICache           cache = CacheFactory.Cache();
            SqlLam <TEntity> sql   = cache.GetCache <SqlLam <TEntity> >(key);

            if (sql == null)
            {
                sql = new SqlLam <TEntity>();
                cache.WriteCache <SqlLam <TEntity> >(sql, key);
            }
            else
            {
                sql.Clear();
            }
            return(sql);
        }
예제 #6
0
 public IEnumerable <TEntity> GetList(SqlLam <TEntity> sql)
 {
     return(connection.Query <TEntity>(sql.SqlString, sql.Parameters));
 }
예제 #7
0
 public TEntity Get(SqlLam <TEntity> sql)
 {
     return(connection.Query <TEntity>(sql.SqlString, sql.Parameters).FirstOrDefault());
 }