예제 #1
0
 public void FormatExtendProperties(MySmo.UserDefinedFunction mysmo_f)
 {
     CombineExtendProperties(mysmo_f.ExtendedProperties);
     if (mysmo_f.FunctionType == MySmo.UserDefinedFunctionType.Table)
     {
         DistributeExtendProperties((MySmo.ITableBase)mysmo_f);
     }
     DistributeExtendProperties((MySmo.IParameterBase)mysmo_f);
 }
예제 #2
0
        public MySmo.UserDefinedFunction GetUserDefinedFunction(Smo.UserDefinedFunction smo_f, MySmo.Database parent = null)
        {
            #region implement

            SetDataLimit();

            var mysmo_f = new MySmo.UserDefinedFunction();

            mysmo_f.ParentDatabase     = parent;
            mysmo_f.Name               = smo_f.Name;
            mysmo_f.Schema             = smo_f.Schema;
            mysmo_f.CreateTime         = smo_f.CreateDate;
            mysmo_f.Owner              = smo_f.Owner;
            mysmo_f.ExtendedProperties = GetExtendProperties(mysmo_f, smo_f.ExtendedProperties);
            var s = "";
            if (mysmo_f.ExtendedProperties.TryGetValue(K_MS_Description, out s))
            {
                mysmo_f.Description = s;
                mysmo_f.ExtendedProperties.Remove(K_MS_Description);
            }
            mysmo_f.Parameters = new List <MySmo.Parameter>();
            foreach (Smo.UserDefinedFunctionParameter smo_p in smo_f.Parameters)
            {
                var mysmo_p = new MySmo.Parameter
                {
                    ParentDatabase      = parent,
                    ParentParameterBase = mysmo_f,
                    Name              = smo_p.Name.Substring(1),
                    DefaultValue      = smo_p.DefaultValue,
                    IsOutputParameter = false,
                    IsReadOnly        = smo_p.IsReadOnly,
                    DataType          = new MySmo.DataType
                    {
                        Name             = smo_p.DataType.Name,
                        Schema           = smo_p.DataType.Schema,
                        MaximumLength    = smo_p.DataType.MaximumLength,
                        NumericPrecision = smo_p.DataType.NumericPrecision,
                        NumericScale     = smo_p.DataType.NumericScale,
                        SqlDataType      = (MySmo.SqlDataType)(int) smo_p.DataType.SqlDataType
                    }
                };
                mysmo_f.Parameters.Add(mysmo_p);
            }
            if (smo_f.FunctionType == Smo.UserDefinedFunctionType.Table)
            {
                mysmo_f.Columns = new List <MySmo.Column>();
                foreach (Smo.Column smo_c in smo_f.Columns)
                {
                    var mysmo_c = new MySmo.Column
                    {
                        ParentDatabase    = parent,
                        ParentTableBase   = mysmo_f,
                        Name              = smo_c.Name,
                        DataType          = GetDataType(smo_c),
                        Computed          = smo_c.Computed,
                        ComputedText      = smo_c.ComputedText,
                        Default           = smo_c.Default,
                        Identity          = smo_c.Identity,
                        IdentityIncrement = smo_c.IdentityIncrement,
                        IdentitySeed      = smo_c.IdentitySeed,
                        InPrimaryKey      = smo_c.InPrimaryKey,
                        IsForeignKey      = smo_c.IsForeignKey,
                        Nullable          = smo_c.Nullable,
                        RowGuidCol        = smo_c.RowGuidCol
                    };
                    mysmo_f.Columns.Add(mysmo_c);
                }
            }
            FormatExtendProperties(mysmo_f);

            return(mysmo_f);

            #endregion
        }