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)); }
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)); }
/// <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)); } }
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 })); } }
public ProxyQueryable(ProxyDbProvider proxyDbProvider, IQueryable baseQueryable) { ProxyDbProvider = proxyDbProvider; BaseQueryable = baseQueryable; }
protected static ProxyQueryable <TElement> CreateQueryNonGenericToGeneric <TElement>(ProxyDbProvider proxy, IQueryable <TElement> query) { return(new ProxyQueryable <TElement>(proxy, query)); }