protected override Expression VisitConstant(ConstantExpression node) { if (node.Type.IsGenericType && (node.Type.GetGenericTypeDefinition() == typeof(IEnumerable <>) || node.Type.GetGenericTypeDefinition() == typeof(IQueryable <>))) { Db.OeEntitySetAdapter entitySetAdapter = _entitySetAdapters.FindByClrType(node.Type.GetGenericArguments()[0]); IQueryable query = entitySetAdapter.GetEntitySet(_dataContext); return(Expression.Constant(query)); } return(base.VisitConstant(node)); }
protected override Db.OeAsyncEnumerator ExecuteReader(Object dataContext, String sql, IReadOnlyList <KeyValuePair <String, Object> > parameters, Type returnType) { var fromSql = (IFromSql)_entitySetAdapters.FindByClrType(returnType); if (fromSql == null) { throw new NotSupportedException("supported only Entity type"); } var query = (IQueryable <Object>)fromSql.FromSql((DbContext)dataContext, sql, GetParameterValues(parameters)); return(new Db.OeAsyncEnumeratorAdapter(query, CancellationToken.None)); }
private ConstantExpression GetQueryConstantExpression(Expression node) { if (node.Type.IsGenericType && node.Type.GetGenericTypeDefinition() == typeof(IQueryable <>)) { Db.OeEntitySetAdapter entitySetAdapter = _entitySetAdapters.FindByClrType(node.Type.GetGenericArguments()[0]); IQueryable query = entitySetAdapter.GetEntitySet(_dataContext); if (_query == null && entitySetAdapter.EntityType == typeof(T)) { _query = (IQueryable <T>)query; } return(Expression.Constant(query)); } return(null); }