コード例 #1
0
 /// <summary>
 ///     Initializes a new instance of Structural Type with the given members
 /// </summary>
 /// <param name="name"> name of the structural type </param>
 /// <param name="namespaceName"> namespace of the structural type </param>
 /// <param name="version"> version of the structural type </param>
 /// <param name="dataSpace"> dataSpace in which this edmtype belongs to </param>
 /// <exception cref="System.ArgumentNullException">Thrown if either name, namespace or version arguments are null</exception>
 internal StructuralType(string name, string namespaceName, DataSpace dataSpace)
     : base(name, namespaceName, dataSpace)
 {
     _members         = new MemberCollection(this);
     _readOnlyMembers = _members.AsReadOnlyMetadataCollection();
 }
コード例 #2
0
 /// <summary>
 ///     Internal parameterless constructor for bootstrapping edmtypes
 /// </summary>
 internal StructuralType()
 {
     _members         = new MemberCollection(this);
     _readOnlyMembers = _members.AsReadOnlyMetadataCollection();
 }
コード例 #3
0
        internal EdmFunction(string name, string namespaceName, DataSpace dataSpace, EdmFunctionPayload payload)
            : base(name, namespaceName, dataSpace)
        {
            //---- name of the 'schema'
            //---- this is used by the SQL Gen utility and update pipeline to support generation of the correct function name in the store
            _schemaName = payload.Schema;

            var returnParameters = payload.ReturnParameters ?? new FunctionParameter[0];

            foreach (var returnParameter in returnParameters)
            {
                if (returnParameter == null)
                {
                    throw new ArgumentException(Strings.ADP_CollectionParameterElementIsNull("ReturnParameters"));
                }

                if (returnParameter.Mode != ParameterMode.ReturnValue)
                {
                    throw new ArgumentException(Strings.NonReturnParameterInReturnParameterCollection);
                }
            }

            _returnParameters = new ReadOnlyMetadataCollection <FunctionParameter>(
                returnParameters
                .Select(
                    (returnParameter) =>
                    SafeLink <EdmFunction> .BindChild(this, FunctionParameter.DeclaringFunctionLinker, returnParameter))
                .ToList());

            if (payload.IsAggregate.HasValue)
            {
                SetFunctionAttribute(ref _functionAttributes, FunctionAttributes.Aggregate, payload.IsAggregate.Value);
            }
            if (payload.IsBuiltIn.HasValue)
            {
                SetFunctionAttribute(ref _functionAttributes, FunctionAttributes.BuiltIn, payload.IsBuiltIn.Value);
            }
            if (payload.IsNiladic.HasValue)
            {
                SetFunctionAttribute(ref _functionAttributes, FunctionAttributes.NiladicFunction, payload.IsNiladic.Value);
            }
            if (payload.IsComposable.HasValue)
            {
                SetFunctionAttribute(ref _functionAttributes, FunctionAttributes.IsComposable, payload.IsComposable.Value);
            }
            if (payload.IsFromProviderManifest.HasValue)
            {
                SetFunctionAttribute(
                    ref _functionAttributes, FunctionAttributes.IsFromProviderManifest, payload.IsFromProviderManifest.Value);
            }
            if (payload.IsCachedStoreFunction.HasValue)
            {
                SetFunctionAttribute(ref _functionAttributes, FunctionAttributes.IsCachedStoreFunction, payload.IsCachedStoreFunction.Value);
            }
            if (payload.IsFunctionImport.HasValue)
            {
                SetFunctionAttribute(ref _functionAttributes, FunctionAttributes.IsFunctionImport, payload.IsFunctionImport.Value);
            }

            if (payload.ParameterTypeSemantics.HasValue)
            {
                _parameterTypeSemantics = payload.ParameterTypeSemantics.Value;
            }

            if (payload.StoreFunctionName != null)
            {
                _storeFunctionNameAttribute = payload.StoreFunctionName;
            }

            if (payload.EntitySets != null)
            {
                if (payload.EntitySets.Length != returnParameters.Length)
                {
                    throw new ArgumentException(Strings.NumberOfEntitySetsDoesNotMatchNumberOfReturnParameters);
                }

                _entitySets = new ReadOnlyMetadataCollection <EntitySet>(payload.EntitySets);
            }
            else
            {
                if (_returnParameters.Count > 1)
                {
                    throw new ArgumentException(Strings.NullEntitySetsForFunctionReturningMultipleResultSets);
                }

                _entitySets = new ReadOnlyMetadataCollection <EntitySet>(_returnParameters.Select(p => (EntitySet)null).ToList());
            }

            if (payload.CommandText != null)
            {
                _commandTextAttribute = payload.CommandText;
            }

            if (payload.Parameters != null)
            {
                // validate the parameters
                foreach (var parameter in payload.Parameters)
                {
                    if (parameter == null)
                    {
                        throw new ArgumentException(Strings.ADP_CollectionParameterElementIsNull("parameters"));
                    }

                    if (parameter.Mode == ParameterMode.ReturnValue)
                    {
                        throw new ArgumentException(Strings.ReturnParameterInInputParameterCollection);
                    }
                }

                // Populate the parameters
                _parameters = new SafeLinkCollection <EdmFunction, FunctionParameter>(
                    this, FunctionParameter.DeclaringFunctionLinker, new MetadataCollection <FunctionParameter>(payload.Parameters));
            }
            else
            {
                _parameters = new ReadOnlyMetadataCollection <FunctionParameter>(new MetadataCollection <FunctionParameter>());
            }
        }
コード例 #4
0
 // <summary>
 // Initializes a new instance of Entity Type
 // </summary>
 // <param name="name"> name of the entity type </param>
 // <param name="namespaceName"> namespace of the entity type </param>
 // <param name="dataSpace"> dataSpace in which this edmtype belongs to </param>
 // <exception cref="System.ArgumentNullException">Thrown if either name, namespace or version arguments are null</exception>
 internal EntityTypeBase(string name, string namespaceName, DataSpace dataSpace)
     : base(name, namespaceName, dataSpace)
 {
     _keyMembers = new ReadOnlyMetadataCollection <EdmMember>(new MetadataCollection <EdmMember>());
 }
コード例 #5
0
        internal EdmFunction(
            string name,
            string namespaceName,
            DataSpace dataSpace,
            EdmFunctionPayload payload)
            : base(name, namespaceName, dataSpace)
        {
            this._schemaName = payload.Schema;
            IList <FunctionParameter> source = payload.ReturnParameters ?? (IList <FunctionParameter>) new FunctionParameter[0];

            foreach (FunctionParameter functionParameter in (IEnumerable <FunctionParameter>)source)
            {
                if (functionParameter == null)
                {
                    throw new ArgumentException(Strings.ADP_CollectionParameterElementIsNull((object)nameof(ReturnParameters)));
                }
                if (functionParameter.Mode != ParameterMode.ReturnValue)
                {
                    throw new ArgumentException(Strings.NonReturnParameterInReturnParameterCollection);
                }
            }
            this._returnParameters = new ReadOnlyMetadataCollection <FunctionParameter>(source.Select <FunctionParameter, FunctionParameter>((Func <FunctionParameter, FunctionParameter>)(returnParameter => SafeLink <EdmFunction> .BindChild <FunctionParameter>(this, FunctionParameter.DeclaringFunctionLinker, returnParameter))).ToList <FunctionParameter>());
            if (payload.IsAggregate.HasValue)
            {
                EdmFunction.SetFunctionAttribute(ref this._functionAttributes, EdmFunction.FunctionAttributes.Aggregate, payload.IsAggregate.Value);
            }
            if (payload.IsBuiltIn.HasValue)
            {
                EdmFunction.SetFunctionAttribute(ref this._functionAttributes, EdmFunction.FunctionAttributes.BuiltIn, payload.IsBuiltIn.Value);
            }
            if (payload.IsNiladic.HasValue)
            {
                EdmFunction.SetFunctionAttribute(ref this._functionAttributes, EdmFunction.FunctionAttributes.NiladicFunction, payload.IsNiladic.Value);
            }
            if (payload.IsComposable.HasValue)
            {
                EdmFunction.SetFunctionAttribute(ref this._functionAttributes, EdmFunction.FunctionAttributes.IsComposable, payload.IsComposable.Value);
            }
            if (payload.IsFromProviderManifest.HasValue)
            {
                EdmFunction.SetFunctionAttribute(ref this._functionAttributes, EdmFunction.FunctionAttributes.IsFromProviderManifest, payload.IsFromProviderManifest.Value);
            }
            if (payload.IsCachedStoreFunction.HasValue)
            {
                EdmFunction.SetFunctionAttribute(ref this._functionAttributes, EdmFunction.FunctionAttributes.IsCachedStoreFunction, payload.IsCachedStoreFunction.Value);
            }
            if (payload.IsFunctionImport.HasValue)
            {
                EdmFunction.SetFunctionAttribute(ref this._functionAttributes, EdmFunction.FunctionAttributes.IsFunctionImport, payload.IsFunctionImport.Value);
            }
            if (payload.ParameterTypeSemantics.HasValue)
            {
                this._parameterTypeSemantics = payload.ParameterTypeSemantics.Value;
            }
            if (payload.StoreFunctionName != null)
            {
                this._storeFunctionNameAttribute = payload.StoreFunctionName;
            }
            if (payload.EntitySets != null)
            {
                if (payload.EntitySets.Count != source.Count)
                {
                    throw new ArgumentException(Strings.NumberOfEntitySetsDoesNotMatchNumberOfReturnParameters);
                }
                this._entitySets = new ReadOnlyCollection <EntitySet>(payload.EntitySets);
            }
            else
            {
                if (this._returnParameters.Count > 1)
                {
                    throw new ArgumentException(Strings.NullEntitySetsForFunctionReturningMultipleResultSets);
                }
                this._entitySets = new ReadOnlyCollection <EntitySet>((IList <EntitySet>) this._returnParameters.Select <FunctionParameter, EntitySet>((Func <FunctionParameter, EntitySet>)(p => (EntitySet)null)).ToList <EntitySet>());
            }
            if (payload.CommandText != null)
            {
                this._commandTextAttribute = payload.CommandText;
            }
            if (payload.Parameters != null)
            {
                foreach (FunctionParameter parameter in (IEnumerable <FunctionParameter>)payload.Parameters)
                {
                    if (parameter == null)
                    {
                        throw new ArgumentException(Strings.ADP_CollectionParameterElementIsNull((object)"parameters"));
                    }
                    if (parameter.Mode == ParameterMode.ReturnValue)
                    {
                        throw new ArgumentException(Strings.ReturnParameterInInputParameterCollection);
                    }
                }
                this._parameters = (ReadOnlyMetadataCollection <FunctionParameter>) new SafeLinkCollection <EdmFunction, FunctionParameter>(this, FunctionParameter.DeclaringFunctionLinker, new MetadataCollection <FunctionParameter>((IEnumerable <FunctionParameter>)payload.Parameters));
            }
            else
            {
                this._parameters = new ReadOnlyMetadataCollection <FunctionParameter>(new MetadataCollection <FunctionParameter>());
            }
        }