Esempio n. 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MetadataProviderEdmFunctionImport"/> class.
 /// </summary>
 /// <param name="model">The model this instance belongs to.</param>
 /// <param name="container">The container this instance belongs to.</param>
 /// <param name="function">The function that is being imported.</param>
 /// <remarks>
 /// This constructor assumes that the entity set for this service operation has already be created.
 /// </remarks>
 internal MetadataProviderEdmFunctionImport(
     MetadataProviderEdmModel model,
     MetadataProviderEdmEntityContainer container,
     MetadataProviderEdmFunction function)
     : base(model, container, function)
 {
     this.Function = function;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="MetadataProviderEdmActionImport"/> class.
 /// </summary>
 /// <param name="model">The model this instance belongs to.</param>
 /// <param name="container">The container this instance belongs to.</param>
 /// <param name="action">The edm action object underlying this function import.</param>
 /// <remarks>
 /// This constructor assumes that the entity set for this service operation has already be created.
 /// </remarks>
 internal MetadataProviderEdmActionImport(
     MetadataProviderEdmModel model, 
     MetadataProviderEdmEntityContainer container, 
     MetadataProviderEdmAction action)
     : base(model, container, action)
 {
     this.Action = action;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="MetadataProviderEdmFunctionImport"/> class.
 /// </summary>
 /// <param name="model">The model this instance belongs to.</param>
 /// <param name="container">The container this instance belongs to.</param>
 /// <param name="function">The function that is being imported.</param>
 /// <remarks>
 /// This constructor assumes that the entity set for this service operation has already be created.
 /// </remarks>
 internal MetadataProviderEdmFunctionImport(
     MetadataProviderEdmModel model, 
     MetadataProviderEdmEntityContainer container, 
     MetadataProviderEdmFunction function)
     : base(model, container, function)
 {
     this.Function = function;
 }
Esempio n. 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MetadataProviderEdmActionImport"/> class.
 /// </summary>
 /// <param name="model">The model this instance belongs to.</param>
 /// <param name="container">The container this instance belongs to.</param>
 /// <param name="action">The edm action object underlying this function import.</param>
 /// <remarks>
 /// This constructor assumes that the entity set for this service operation has already be created.
 /// </remarks>
 internal MetadataProviderEdmActionImport(
     MetadataProviderEdmModel model,
     MetadataProviderEdmEntityContainer container,
     MetadataProviderEdmAction action)
     : base(model, container, action)
 {
     this.Action = action;
 }
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="model">The edm model this instance belongs to.</param>
        /// <param name="entityContainer">Entity container instance that this set belongs to.</param>
        /// <param name="resourceSet">ResourceSet that this entity set represents.</param>
        internal MetadataProviderEdmEntitySet(MetadataProviderEdmModel model, MetadataProviderEdmEntityContainer entityContainer, ResourceSetWrapper resourceSet)
        {
            Debug.Assert(model != null, "model != null");
            Debug.Assert(entityContainer != null, "entityContainer != null");
            Debug.Assert(resourceSet != null, "resourceSet != null");

            this.model           = model;
            this.entityContainer = entityContainer;
            this.resourceSet     = resourceSet;
        }
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="model">The edm model this instance belongs to.</param>
        /// <param name="entityContainer">Entity container instance that this set belongs to.</param>
        /// <param name="resourceSet">ResourceSet that this entity set represents.</param>
        internal MetadataProviderEdmEntitySet(MetadataProviderEdmModel model, MetadataProviderEdmEntityContainer entityContainer, ResourceSetWrapper resourceSet)
        {
            Debug.Assert(model != null, "model != null");
            Debug.Assert(entityContainer != null, "entityContainer != null");
            Debug.Assert(resourceSet != null, "resourceSet != null");

            this.model = model;
            this.entityContainer = entityContainer;
            this.resourceSet = resourceSet;
        }
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="model">The model this instance belongs to.</param>
        /// <param name="container">The container this instance belongs to.</param>
        /// <param name="edmOperation">The edm operation underlying this function import.</param>
        /// <remarks>This constructor assumes that the entity set for this service operation has already be created.</remarks>
        protected internal MetadataProviderEdmOperationImport(
            MetadataProviderEdmModel model, 
            MetadataProviderEdmEntityContainer container,
            MetadataProviderEdmOperation edmOperation)
        {
            Debug.Assert(model != null, "model != null");
            Debug.Assert(container != null, "container != null");
            Debug.Assert(edmOperation != null, "edmOperation != null");

            this.container = container;
            this.model = model;
            this.edmOperation = edmOperation;

            // EntitySetPath=<path string>
            ResourceSetPathExpression resultSetPathExpression = edmOperation.ServiceOperation.ResultSetPathExpression;
            this.entitySetPath = resultSetPathExpression == null ? null : resultSetPathExpression.PathExpression;
        }
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="model">The model this instance belongs to.</param>
        /// <param name="container">The container this instance belongs to.</param>
        /// <param name="edmOperation">The edm operation underlying this function import.</param>
        /// <remarks>This constructor assumes that the entity set for this service operation has already be created.</remarks>
        protected internal MetadataProviderEdmOperationImport(
            MetadataProviderEdmModel model,
            MetadataProviderEdmEntityContainer container,
            MetadataProviderEdmOperation edmOperation)
        {
            Debug.Assert(model != null, "model != null");
            Debug.Assert(container != null, "container != null");
            Debug.Assert(edmOperation != null, "edmOperation != null");

            this.container    = container;
            this.model        = model;
            this.edmOperation = edmOperation;

            // EntitySetPath=<path string>
            ResourceSetPathExpression resultSetPathExpression = edmOperation.ServiceOperation.ResultSetPathExpression;

            this.entitySetPath = resultSetPathExpression == null ? null : resultSetPathExpression.PathExpression;
        }
        /// <summary>
        /// Add the given entity set to the model.
        /// </summary>
        /// <param name="resourceSet">ResourceSetWrapper instance to add.</param>
        /// <returns>an instance of IEdmEntitySet for the given <paramref name="resourceSet"/>.</returns>
        internal IEdmEntitySet EnsureEntitySet(ResourceSetWrapper resourceSet)
        {
            this.EnsureDefaultEntityContainer();

            // Make sure if the entity container exists
            string entityContainerName = resourceSet.EntityContainerName ?? this.metadataProvider.ContainerName;
            MetadataProviderEdmEntityContainer entityContainer = this.FindExistingEntityContainer(entityContainerName);
            if (entityContainer == null)
            {
                entityContainer = new MetadataProviderEdmEntityContainer(this, entityContainerName, this.GetContainerNamespace());
                MetadataProviderUtils.ConvertCustomAnnotations(this, this.metadataProvider.GetEntityContainerAnnotations(entityContainerName), entityContainer);
                this.entityContainerCache.Add(entityContainerName, entityContainer);
                this.entityContainerCache.Add(entityContainer.FullName(), entityContainer);
            }

            string entitySetName = MetadataProviderUtils.GetEntitySetName(resourceSet.ResourceSet);
            IEdmEntitySet entitySet = entityContainer.FindEntitySet(entitySetName);
            if (entitySet == null)
            {
                entitySet = entityContainer.AddEntitySet(entitySetName, resourceSet);
            }

            return entitySet;
        }
        /// <summary>
        /// Gets or creates the default entity container.
        /// </summary>
        /// <returns>The default entity container.</returns>
        internal MetadataProviderEdmEntityContainer EnsureDefaultEntityContainer()
        {
            // Get the default container name.
            string defaultContainerName = this.metadataProvider.ContainerName;
            Debug.Assert(!string.IsNullOrEmpty(defaultContainerName), "!string.IsNullOrEmpty(defaultContainerName)");

            MetadataProviderEdmEntityContainer defaultContainer;
            if (!this.entityContainerCache.TryGetValue(defaultContainerName, out defaultContainer))
            {
                defaultContainer = new MetadataProviderEdmEntityContainer(this, defaultContainerName, this.GetContainerNamespace());
                MetadataProviderUtils.ConvertCustomAnnotations(this, this.metadataProvider.GetEntityContainerAnnotations(defaultContainerName), defaultContainer);
                this.entityContainerCache.Add(defaultContainerName, defaultContainer);
                this.entityContainerCache.Add(defaultContainer.FullName(), defaultContainer);
            }

            Debug.Assert(defaultContainer != null, "defaultContainer != null");
            return defaultContainer;
        }