internal static CsdlEntityContainer EntityContainer( string name, string extends = null, CsdlEntitySet[] entitySets = default(CsdlEntitySet[]), CsdlSingleton[] singletons = default(CsdlSingleton[]), CsdlOperationImport[] operationImports = default(CsdlOperationImport[]), CsdlLocation location = null) { if (entitySets == null) { entitySets = new CsdlEntitySet[] { }; } if (operationImports == null) { operationImports = new CsdlOperationImport[] { }; } if (singletons == null) { singletons = new CsdlSingleton[] { }; } return(new CsdlEntityContainer( name, extends, entitySets, singletons, operationImports, location)); }
public void ParseCsdlEntityContainerWithMembersWorksAsExpected() { string json = @"""DemoService"": { ""$Kind"": ""EntityContainer"", ""Products"": { ""$Type"": ""self.Product"", ""$Collection"": true }, ""Me"": { ""$Type"": ""self.User"" }, ""LeaveRequestApproval"": { ""$Action"": ""self.Approval"" }, ""ProductsByRating"": { ""$EntitySet"": ""Products"", ""$Function"": ""self.ProductsByRating"" }, ""@UI.DisplayName"": ""Supplier Directory"" }"; CsdlEntityContainer entityContainer = ParseCsdlSchemaElement(json, SchemaJsonParser.ParseCsdlEntityContainer); Assert.NotNull(entityContainer); Assert.Equal("DemoService", entityContainer.Name); CsdlEntitySet entitySet = Assert.Single(entityContainer.EntitySets); Assert.Equal("Products", entitySet.Name); CsdlSingleton singleton = Assert.Single(entityContainer.Singletons); Assert.Equal("Me", singleton.Name); Assert.Equal(2, entityContainer.OperationImports.Count()); CsdlActionImport actionImport = Assert.Single(entityContainer.OperationImports.OfType <CsdlActionImport>()); Assert.Equal("LeaveRequestApproval", actionImport.Name); CsdlFunctionImport functionImport = Assert.Single(entityContainer.OperationImports.OfType <CsdlFunctionImport>()); Assert.Equal("ProductsByRating", functionImport.Name); CsdlAnnotation annotation = Assert.Single(entityContainer.VocabularyAnnotations); Assert.Equal("UI.DisplayName", annotation.Term); Assert.IsType <CsdlConstantExpression>(annotation.Expression); }
public void EnsureEntitySetReferenceNotResolveToSingleton() { var action = CsdlBuilder.Action("Checkout"); var actionImport = new CsdlActionImport("Checkout", "FQ.NS.Checkout", "Singleton" /*entitySet*/, null /*documentation*/, testLocation); var csdlSingleton = new CsdlSingleton("Singleton", "FQ.NS.EntityType", Enumerable.Empty <CsdlNavigationPropertyBinding>(), null, testLocation); var csdlEntityContainer = CsdlBuilder.EntityContainer("Container", singletons: new[] { csdlSingleton }); var semanticSchema = CreateCsdlSemanticsSchema(csdlEntityContainer, action); var semanticAction = new CsdlSemanticsAction(semanticSchema, action); var csdlSemanticEntityContainer = new CsdlSemanticsEntityContainer(semanticSchema, csdlEntityContainer); var semanticActionImport = new CsdlSemanticsActionImport(csdlSemanticEntityContainer, actionImport, semanticAction); semanticActionImport.Action.Should().NotBeNull(); semanticActionImport.Action.Name.Should().Be("Checkout"); var edmEntitySetReference = (IEdmEntitySetReferenceExpression)semanticActionImport.EntitySet; edmEntitySetReference.ReferencedEntitySet.GetType().Should().Be(typeof(UnresolvedEntitySet)); edmEntitySetReference.ReferencedEntitySet.Name.Should().Be("Singleton"); }
public CsdlSemanticsSingleton(CsdlSemanticsEntityContainer container, CsdlSingleton singleton) : base(container, singleton) { }