예제 #1
0
        public override List <T> Select <T>(Expression where)
        {
            var tableName = typeof(T).Name;
            var sql       = new StringBuilder($@"select * from {tableName} where {ExpressionAnalyze.Where(where)}");

            return(dataOperator.QueryObject <T>(sql.ToString()));
        }
예제 #2
0
        public override int Count <T>(Expression where)
        {
            var sqlTemp = @"
select count(1) from {0}
 where {1}";
            var sql     = string.Format(sqlTemp, typeof(T).Name, ExpressionAnalyze.Where(where));

            return((int)Convert.ChangeType(this.dataOperator.ExecuteSclar(sql), typeof(int)));
        }
예제 #3
0
        public override List <T> Select <T>(LambdaExpression where, LambdaExpression orderBy, ConstantExpression take)
        {
            var tableName = typeof(T).Name;
            var sql       = new StringBuilder($@"
select * from {tableName} 
 where {ExpressionAnalyze.Where(where)}");

            if (orderBy != null)
            {
                sql.Append($@"
 order by {ExpressionAnalyze.OrderBy(orderBy)}");
            }
            if (take != null)
            {
                sql.Append($@"
 limit 0, {ExpressionAnalyze.OrderBy(take)}");
            }
            return(dataOperator.QueryObject <T>(sql.ToString()));
        }