Ejemplo n.º 1
0
        /// <summary>
        /// Execute Quary
        /// </summary>
        /// <param name="expression"></param>
        /// <returns></returns>
        public object Execute(Expression expression)
        {
            var _expression = new LightDataLinqToNoSql(expression.Type.GetActualType(), this);

            _expression.Translate(expression);
            return(_dbSchema.Select(expression.Type, _expression.Quary));
        }
Ejemplo n.º 2
0
 internal SqlQueryable(Expression exp, Transaction.Transaction repository)
 {
     _repository = repository;
     _expression = new LightDataLinqToNoSql(typeof(T), _repository);
     if (exp != null)
     {
         _matches.Add(exp);
     }
 }
Ejemplo n.º 3
0
 internal SqlQueryable(Transaction.Transaction repository, List <T> items)
 {
     _repository = repository;
     _expression = new LightDataLinqToNoSql(typeof(T), _repository);
     if (items == null)
     {
         return;
     }
     PartExecuted = true;
     items.RemoveAll(x => x == null);
     base.AddRange(items);
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Return the count of the executed quary
        /// </summary>
        /// <returns></returns>
        public int ExecuteCount()
        {
            _expression.DataBaseTypes = _repository.DataBaseTypes;
            foreach (var exp in _matches)
            {
                _expression.Translate(exp);
            }
            ParsedLinqToSql = _expression.Count;
            _expression     = new LightDataLinqToNoSql(typeof(T));// reset
            var cmd = _repository.GetSqlCommand(ParsedLinqToSql);

            return(_repository.ExecuteScalar(cmd).ConvertValue <int>());
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Execute generic quary
        /// </summary>
        /// <typeparam name="TResult"></typeparam>
        /// <param name="expression"></param>
        /// <returns></returns>
        public TResult Execute <TResult>(Expression expression)
        {
            var isEnumerable = (typeof(TResult).Name == "IEnumerable`1");
            var _expression  = new LightDataLinqToNoSql(typeof(TResult).GetActualType(), this);

            _expression.Translate(expression);
            if (!isEnumerable)
            {
                return(Select <TResult>(_expression.Quary).First());
            }
            else
            {
                return((TResult)_dbSchema.Select(expression.Type, _expression.Quary));
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// select by quarry
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="repository"></param>
        /// <param name="quary"></param>
        /// <returns></returns>
        internal static async Task <List <T> > WhereAsync <T>(this ICustomRepository repository, LightDataLinqToNoSql <T> quary = null) where T : class, IDbEntity
        {
            var sql = quary?.Quary;

            return(await Task.Run(() => DbSchema.Where <T>(repository, sql)));
        }
Ejemplo n.º 7
0
        /// <summary>
        /// select by quarry
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="repository"></param>
        /// <param name="quary"></param>
        /// <returns></returns>
        internal static List <T> Where <T>(this ICustomRepository repository, LightDataLinqToNoSql <T> quary = null) where T : class, IDbEntity
        {
            var sql = quary?.Quary;

            return(DbSchema.Where <T>(repository, sql));
        }