Ejemplo n.º 1
0
 public virtual void Quering_nested_entity_directly_throws()
 {
     using (CreateTestStore(OnModelCreating))
     {
         using (var context = CreateContext())
         {
             Assert.Equal(CosmosStrings.QueryRootNestedEntityType(nameof(Operator), nameof(Vehicle)),
                          Assert.Throws <InvalidOperationException>(() => context.Set <Operator>().ToList()).Message);
         }
     }
 }
Ejemplo n.º 2
0
        protected override Expression VisitEntityQueryable([NotNull] Type elementType)
        {
            var entityType = _model.FindEntityType(elementType);

            if (!entityType.IsDocumentRoot())
            {
                throw new InvalidOperationException(
                          CosmosStrings.QueryRootNestedEntityType(entityType.DisplayName(), entityType.FindOwnership().PrincipalEntityType.DisplayName()));
            }

            return(new QueryShaperExpression(
                       QueryModelVisitor.QueryCompilationContext.IsAsyncQuery,
                       new DocumentQueryExpression(
                           QueryModelVisitor.QueryCompilationContext.IsAsyncQuery,
                           entityType.Cosmos().ContainerName,
                           new SelectExpression(entityType, _querySource)),
                       new EntityShaper(entityType,
                                        trackingQuery: QueryModelVisitor.QueryCompilationContext.IsTrackingQuery &&
                                        !entityType.IsQueryType,
                                        useQueryBuffer: QueryModelVisitor.QueryCompilationContext.IsQueryBufferRequired &&
                                        !entityType.IsQueryType,
                                        _entityMaterializerSource)));
        }