internal ModelFunctionParameter(EDMXFile parentFile, ModelFunction storeFunction, string name, int ordinal, XmlElement parentTypeElement)
            : base(parentFile)
        {
            _parentFunction = storeFunction;

            _parameterElement = EDMXDocument.CreateElement("Parameter", NameSpaceURIcsdl);
            if (ordinal > 0)
            {
                XmlNodeList propertyNodes = parentTypeElement.SelectNodes("edm:Parameter", NSM);
                if (propertyNodes.Count >= ordinal)
                {
                    parentTypeElement.InsertAfter(_parameterElement, propertyNodes[ordinal - 1]);
                }
                else
                {
                    parentTypeElement.AppendChild(_parameterElement);
                }
            }
            else
            {
                parentTypeElement.AppendChild(_parameterElement);
            }

            this.Name = name;
        }
 internal FunctionImportMapping(EDMXFile parentFile, CSMapping csMapping, XmlElement fimElement)
     : base(parentFile)
 {
     _csMapping  = csMapping;
     _fimElement = fimElement;
     ModelFunction mf = this.ModelFunction;
 }
Example #3
0
 /// <summary>
 /// Adds a function import to the model.
 /// </summary>
 /// <param name="name"></param>
 /// <returns></returns>
 public ModelFunction AddFunctionImport(string name)
 {
     try
     {
         if (!EntityTypes.Any(et => et.Name == name) &&
             !FunctionImports.Any(mf => mf.Name == name))
         {
             ModelFunction mf = new ModelFunction(ParentFile, this, name);
             _modelFunctionImports.Add(name, mf);
             mf.NameChanged += new EventHandler <NameChangeArgs>(mf_NameChanged);
             mf.Removed     += new EventHandler(mf_Removed);
             return(mf);
         }
         else
         {
             throw new ArgumentException("A function with the name " + name + " already exist in the model.");
         }
     }
     catch (Exception ex)
     {
         try
         {
             if (!ex.Data.Contains("EDMXType"))
             {
                 ex.Data.Add("EDMXType", this.GetType().Name);
             }
             if (!ex.Data.Contains("EDMXObjectName"))
             {
                 ex.Data.Add("EDMXObjectName", this.ContainerName);
             }
         }
         catch { }
         throw;
     }
 }
        internal ModelFunctionParameter(EDMXFile parentFile, ModelFunction storeFunction, string name, int ordinal, XmlElement parentTypeElement)
            : base(parentFile)
        {
            _parentFunction = storeFunction;

            _parameterElement = EDMXDocument.CreateElement("Parameter", NameSpaceURIcsdl);
            if (ordinal > 0)
            {
                XmlNodeList propertyNodes = parentTypeElement.SelectNodes("edm:Parameter", NSM);
                if (propertyNodes.Count >= ordinal)
                {
                    parentTypeElement.InsertAfter(_parameterElement, propertyNodes[ordinal - 1]);
                }
                else
                {
                    parentTypeElement.AppendChild(_parameterElement);
                }
            }
            else
            {
                parentTypeElement.AppendChild(_parameterElement);
            }

            this.Name = name;
        }
Example #5
0
        /// <summary>
        /// Adds a mapping between a model function and a store function.
        /// </summary>
        /// <param name="modelFunction">Model function import to map.</param>
        /// <param name="storeFunction">Store function to map the model function to.</param>
        /// <returns>A FunctionImportMapping object representing the new mapping.</returns>
        public FunctionImportMapping AddMapping(ModelFunction modelFunction, StoreFunction storeFunction)
        {
            FunctionImportMapping fim = new FunctionImportMapping(base.ParentFile, _entityContainerMapping, this, modelFunction, storeFunction);

            _functionImportMappings.Add(fim.ModelFunction.Name, fim);
            fim.Removed += new EventHandler(fim_Removed);
            fim.ModelFunction.NameChanged += new EventHandler <NameChangeArgs>(ModelFunction_NameChanged);
            return(fim);
        }
        internal FunctionImportMapping(EDMXFile parentFile, XmlElement entityContainerMappingElement, CSMapping csMapping, ModelFunction modelFunction, StoreFunction storeFunction)
            : base(parentFile)
        {
            _csMapping = csMapping;

            _modelFunction              = modelFunction;
            _modelFunction.NameChanged += new EventHandler <NameChangeArgs>(ModelFunction_NameChanged);
            _modelFunction.Removed     += new EventHandler(ModelFunction_Removed);

            _storeFunction          = storeFunction;
            _storeFunction.Removed += new EventHandler(StoreFunction_Removed);
        }
Example #7
0
 /// <summary>
 /// Adds a mapping between a model function and a store function.
 /// </summary>
 /// <param name="modelFunction">Model function import to map.</param>
 /// <param name="storeFunction">Store function to map the model function to.</param>
 /// <returns>A FunctionImportMapping object representing the new mapping.</returns>
 public FunctionImportMapping AddMapping(ModelFunction modelFunction, StoreFunction storeFunction)
 {
     FunctionImportMapping fim = new FunctionImportMapping(base.ParentFile, _entityContainerMapping, this, modelFunction, storeFunction);
     _functionImportMappings.Add(fim.ModelFunction.Name, fim);
     fim.Removed += new EventHandler(fim_Removed);
     fim.ModelFunction.NameChanged += new EventHandler<NameChangeArgs>(ModelFunction_NameChanged);
     return fim;
 }
 void ModelFunction_Removed(object sender, EventArgs e)
 {
     this.Remove();
     _modelFunction = null;
 }
 internal ModelFunctionParameter(EDMXFile parentFile, ModelFunction parentFunction, XmlElement parameterElement)
     : base(parentFile)
 {
     _parentFunction = parentFunction;
     _parameterElement = parameterElement;
 }
 /// <summary>
 /// Adds a function import to the model.
 /// </summary>
 /// <param name="name"></param>
 /// <returns></returns>
 public ModelFunction AddFunctionImport(string name)
 {
     try
     {
         if (!EntityTypes.Any(et => et.Name == name)
             && !FunctionImports.Any(mf => mf.Name == name))
         {
             ModelFunction mf = new ModelFunction(ParentFile, this, name);
             _modelFunctionImports.Add(name, mf);
             mf.NameChanged += new EventHandler<NameChangeArgs>(mf_NameChanged);
             mf.Removed += new EventHandler(mf_Removed);
             return mf;
         }
         else
         {
             throw new ArgumentException("A function with the name " + name + " already exist in the model.");
         }
     }
     catch (Exception ex)
     {
         try
         {
             if (!ex.Data.Contains("EDMXType"))
             {
                 ex.Data.Add("EDMXType", this.GetType().Name);
             }
             if (!ex.Data.Contains("EDMXObjectName"))
             {
                 ex.Data.Add("EDMXObjectName", this.ContainerName);
             }
         }
         catch { }
         throw;
     }
 }
 internal ModelFunctionParameter(EDMXFile parentFile, ModelFunction parentFunction, XmlElement parameterElement)
     : base(parentFile)
 {
     _parentFunction   = parentFunction;
     _parameterElement = parameterElement;
 }