public static Expression Find(Expression expression, Type type) { var finder = new TypedSubtreeFinder(type); finder.Visit(expression); return(finder.root); }
private Expression FindProviderInExpression(Expression expression) { Expression root = TypedSubtreeFinder.Find(expression, typeof(IQueryProvider)); if (root == null) { root = TypedSubtreeFinder.Find(expression, typeof(IQueryable)); } return(root); }
private IQueryProvider FindProvider(Expression expression) { var root = TypedSubtreeFinder.Find(expression, typeof(IQueryProvider)) as ConstantExpression; if (root == null) { root = TypedSubtreeFinder.Find(expression, typeof(IQueryable)) as ConstantExpression; } if (root != null) { var provider = root.Value as IQueryProvider; if (provider == null) { var query = root.Value as IQueryable; if (query != null) { provider = query.Provider; } } return(provider); } return(null); }