예제 #1
0
        IQueryable <TElement> IQueryProvider.CreateQuery <TElement>(Expression expression)
        {
            //
            // Here we're on the edge between IQbservable and IQueryable for the local
            // execution case. E.g.:
            //
            //   observable.AsQbservable().<operators>.ToQueryable()
            //
            // This should be turned into a local execution, with the push-to-pull
            // adapter in the middle, so we rewrite to:
            //
            //   observable.AsQbservable().<operators>.ToEnumerable().AsQueryable()
            //
            if (!(expression is MethodCallExpression call) ||
                call.Method.DeclaringType != typeof(Qbservable) ||
                call.Method.Name != nameof(Qbservable.ToQueryable))
            {
                throw new ArgumentException(Strings_Providers.EXPECTED_TOQUERYABLE_METHODCALL, nameof(expression));
            }

            //
            // This is the IQbservable<T> object corresponding to the lhs. Now wrap
            // it in two calls to get the local queryable.
            //
            var arg0 = call.Arguments[0];
            var res  =
                Expression.Call(
                    AsQueryable.MakeGenericMethod(typeof(TElement)),
                    Expression.Call(
                        typeof(Observable).GetMethod(nameof(Observable.ToEnumerable)) !.MakeGenericMethod(typeof(TElement)),
                        arg0
                        )
                    );

            //
            // Queryable operator calls should be taken care of by the provider for
            // LINQ to Objects. So we compile and get the resulting IQueryable<T>
            // back to hand it out.
            //
            return(Expression.Lambda <Func <IQueryable <TElement> > >(res).Compile()());
        }
예제 #2
0
        public bool CodigoBarraExiste(string codigoBarra)
        {
            var query = AsQueryable.FirstOrDefault(x => x.CodigoBarra == codigoBarra);

            return(query != null);
        }
예제 #3
0
        public ProdutoEntity GetByCodigoBarras(string codigoBarra)
        {
            var result = AsQueryable.FirstOrDefault(x => x.CodigoBarra == codigoBarra);

            return(result);
        }
예제 #4
0
        public int ProdutoTotalPedidos(Guid produtoId)
        {
            var result = AsQueryable.Where(x => x.Produtos.Any(y => y.Id == produtoId));

            return(result.Count());
        }
예제 #5
0
        public bool CodigoExsite(string codigo)
        {
            var first = AsQueryable.FirstOrDefault(x => x.Codigo == codigo);

            return(first != null);
        }
예제 #6
0
 public List <PureMongoDynamicRecord> GetResult()
 {
     return(AsQueryable.ToList());
 }
예제 #7
0
        public int ClienteTotalPedidos(Guid clienteId)
        {
            var result = AsQueryable.Where(x => x.ClienteId == clienteId);

            return(result.Count());
        }
예제 #8
0
파일: Repository.cs 프로젝트: mrtcn/upope
 public TEntity FirstOrDefault(Expression <Func <TEntity, bool> > predicate = null)
 {
     return(AsQueryable.FirstOrDefault(predicate ?? (x => true)));
 }
예제 #9
0
파일: Repository.cs 프로젝트: mrtcn/upope
 public async Task <TEntity> FirstOrDefaultAsync(Expression <Func <TEntity, bool> > predicate = null)
 {
     return(await AsQueryable.FirstOrDefaultAsync(predicate ?? (x => true)));
 }
예제 #10
0
파일: Repository.cs 프로젝트: mrtcn/upope
 public virtual IQueryable <TEntity> Find(Expression <Func <TEntity, bool> > predicate = null)
 {
     return(AsQueryable.Where(predicate ?? (x => true)));
 }
예제 #11
0
파일: Repository.cs 프로젝트: mrtcn/upope
 public virtual async Task <TEntity> SingleOrDefaultAsync(Expression <Func <TEntity, bool> > predicate = null)
 {
     return(await AsQueryable.SingleOrDefaultAsync(predicate ?? (x => true)));
 }
예제 #12
0
파일: Repository.cs 프로젝트: mrtcn/upope
 public virtual TEntity SingleOrDefault(Expression <Func <TEntity, bool> > predicate = null)
 {
     return(AsQueryable.SingleOrDefault(predicate ?? (x => true)));
 }
예제 #13
0
 public bool CodigoExiste(string codigo)
 {
     var entity = AsQueryable.FirstOrDefault(x => x.Codigo == codigo);
     return entity != null;
 }
예제 #14
0
 public bool CpfExiste(string cpf)
 {
     var entity = AsQueryable.FirstOrDefault(x => x.Cpf == cpf);
     return entity != null;
 }