Exemple #1
0
        internal static CsdlEntityContainer EntityContainer(
            string name,
            string extends = null,
            CsdlEntitySet[] entitySets = default(CsdlEntitySet[]),
            CsdlSingleton[] singletons = default(CsdlSingleton[]),
            CsdlOperationImport[] operationImports = default(CsdlOperationImport[]),
            CsdlDocumentation documentation = null,
            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,
                documentation,
                location);
        }
        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)
 {
 }