コード例 #1
0
        public ProxyDbSet(DbSet <TEntity> baseDbSet, Func <Expression, Expression> manipulator = null)
        {
            IQueryProvider  provider        = ((IQueryable)baseDbSet).Provider;
            ProxyDbProvider proxyDbProvider = new ProxyDbProvider(provider, manipulator);

            ProxyQueryable = (ProxyQueryable <TEntity>)(proxyDbProvider.CreateQuery <TEntity>(((IQueryable)baseDbSet).Expression));
        }
コード例 #2
0
        public IQueryable <TElement> CreateQuery <TElement>(Expression expression)
        {
            Expression expression2 = Manipulator != null?Manipulator(false, expression) : expression;

            IQueryable <TElement> query    = BaseQueryProvider.CreateQuery <TElement>(expression2);
            IQueryProvider        provider = query.Provider;
            ProxyDbProvider       proxy    = provider == BaseQueryProvider ? this : new ProxyDbProvider(provider, Manipulator);

            return(new ProxyQueryable <TElement>(proxy, query));
        }
コード例 #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="baseDbSet"></param>
        /// <param name="manipulator">First parameter: true for Execute, false for CreateQuery.</param>
        public ProxyDbSet(DbSet <TEntity> baseDbSet, Func <bool, Expression, Expression> manipulator)
        {
            BaseDbSet = baseDbSet;
            IQueryProvider  provider        = ((IQueryable)baseDbSet).Provider;
            ProxyDbProvider proxyDbProvider = new ProxyDbProvider(provider, manipulator);

            ProxyQueryable = proxyDbProvider.CreateQuery <TEntity>(((IQueryable)baseDbSet).Expression);
            Manipulator    = manipulator;
            if (InternalSetField != null)
            {
                InternalSetField.SetValue(this, InternalSetField.GetValue(baseDbSet));
            }
        }
コード例 #4
0
        public IQueryable CreateQuery(Expression expression)
        {
            Expression expression2 = Manipulator != null?Manipulator(false, expression) : expression;

            IQueryable      query      = BaseQueryProvider.CreateQuery(expression2);
            IQueryProvider  provider   = query.Provider;
            ProxyDbProvider proxy      = provider == BaseQueryProvider ? this : new ProxyDbProvider(provider, Manipulator);
            Type            entityType = GetIQueryableTypeArgument(query.GetType());

            if (entityType == null)
            {
                return(new ProxyQueryable(proxy, query));
            }
            else
            {
                return((IQueryable)CreateQueryNonGenericToGenericMethod.MakeGenericMethod(entityType).Invoke(null, new object[] { proxy, query }));
            }
        }
コード例 #5
0
 public ProxyQueryable(ProxyDbProvider proxyDbProvider, IQueryable baseQueryable)
 {
     ProxyDbProvider = proxyDbProvider;
     BaseQueryable   = baseQueryable;
 }
コード例 #6
0
 protected static ProxyQueryable <TElement> CreateQueryNonGenericToGeneric <TElement>(ProxyDbProvider proxy, IQueryable <TElement> query)
 {
     return(new ProxyQueryable <TElement>(proxy, query));
 }