Esempio n. 1
0
 /// <summary>
 /// Initializes a new instance of IdentityMap.
 /// </summary>
 /// <param name="owner"><see cref="T:FieldMap"/> this identity belongs to.</param>
 /// <param name="format"><see cref="T:IdentityFormat"/> of the identity.</param>
 /// <param name="increment"><see cref="T:IdentityIncrement"/> of the identity.</param>
 public IdentityMap( FieldMap owner, IdentityFormat format, IdentityIncrement increment )
 {
     this.Owner = owner;
     this.Format = format;
     this.Increment = increment;
     if ( this.Format == IdentityFormat.Guid ) { this.UnsavedValue = new Guid(); }
     else if ( this.Format == IdentityFormat.Integer ) { this.UnsavedValue = 0; }
     else if ( this.Format == IdentityFormat.String ) { this.UnsavedValue = String.Empty; }
 }
Esempio n. 2
0
        /// <summary>
        /// Devuelve el schema de la columna en formato SQL.
        /// </summary>
        public string ToSQL(Boolean sqlConstraint)
        {
            string sql = "";

            sql += "\t[" + Name + "] ";
            if (!IsComputed)
            {
                sql += "[" + Type + "]";
                if (Type.Equals("varbinary") || Type.Equals("varchar") || Type.Equals("char") || Type.Equals("nchar") || Type.Equals("nvarchar"))
                {
                    sql += " (" + Size.ToString() + ")";
                }
                if (Type.Equals("numeric") || Type.Equals("decimal"))
                {
                    sql += " (" + Precision.ToString() + "," + Scale.ToString() + ")";
                }
                if (!String.IsNullOrEmpty(Collation))
                {
                    sql += " COLLATE " + Collation;
                }
                if (Identity)
                {
                    sql += " IDENTITY (" + IdentitySeed.ToString() + "," + IdentityIncrement.ToString() + ")";
                }
                if (IdentityForReplication)
                {
                    sql += " NOT FOR REPLICATION";
                }
                if (Nullable)
                {
                    sql += " NULL";
                }
                else
                {
                    sql += " NOT NULL";
                }
                if (IsRowGuid)
                {
                    sql += " ROWGUIDCOL";
                }
            }
            else
            {
                sql += "AS " + computedFormula;
            }
            if ((sqlConstraint) && (constraints.Count > 0))
            {
                sql += " " + constraints.ToSQL();
            }
            return(sql);
        }
Esempio n. 3
0
        public override DbTypeBase ToGenericType()
        {
            DbTypeNumeric res = new DbTypeNumeric();

            res.Precision = Precision;
            res.Scale     = Scale;
            if (IsIdentity)
            {
                res.Autoincrement = true;
                res.SetSpecificAttribute("effiproz", "identity_increment", IdentityIncrement.ToString());
                res.SetSpecificAttribute("effiproz", "identity_seed", IdentitySeed.ToString());
            }
            return(res);
        }
Esempio n. 4
0
        public override DbTypeBase ToGenericType()
        {
            DbTypeInt res = new DbTypeInt();

            res.Bytes    = Bytes;
            res.Unsigned = false;
            if (IsIdentity)
            {
                res.Autoincrement = true;
                res.SetSpecificAttribute("effiproz", "identity_increment", IdentityIncrement.ToString());
                res.SetSpecificAttribute("effiproz", "identity_seed", IdentitySeed.ToString());
            }
            return(res);
        }
Esempio n. 5
0
        /// <summary>
        /// Devuelve el schema de la columna en formato SQL.
        /// </summary>
        public string ToSql(Boolean sqlConstraint)
        {
            string sql = "";

            sql += "[" + Name + "] ";
            if (!IsComputed)
            {
                if (this.IsUserDefinedType)
                {
                    sql += Type;
                }
                else
                {
                    sql += "[" + Type + "]";
                }
                if (Type.Equals("binary") || Type.Equals("varbinary") || Type.Equals("varchar") || Type.Equals("char") || Type.Equals("nchar") || Type.Equals("nvarchar"))
                {
                    if (Size == -1)
                    {
                        sql += " (max)";
                    }
                    else
                    {
                        if (Type.Equals("nchar") || Type.Equals("nvarchar"))
                        {
                            sql += " (" + (Size / 2).ToString(CultureInfo.InvariantCulture) + ")";
                        }
                        else
                        {
                            sql += " (" + Size.ToString(CultureInfo.InvariantCulture) + ")";
                        }
                    }
                }
                if (Type.Equals("xml"))
                {
                    if (!String.IsNullOrEmpty(XmlSchema))
                    {
                        if (IsXmlDocument)
                        {
                            sql += "(DOCUMENT " + XmlSchema + ")";
                        }
                        else
                        {
                            sql += "(CONTENT " + XmlSchema + ")";
                        }
                    }
                }
                if (Type.Equals("numeric") || Type.Equals("decimal"))
                {
                    sql += " (" + Precision.ToString(CultureInfo.InvariantCulture) + "," + Scale.ToString(CultureInfo.InvariantCulture) + ")";
                }
                if (((Database)Parent.Parent).Info.Version >= DatabaseInfo.VersionTypeEnum.SQLServer2008)
                {
                    if (Type.Equals("datetime2") || Type.Equals("datetimeoffset") || Type.Equals("time"))
                    {
                        sql += "(" + Scale.ToString(CultureInfo.InvariantCulture) + ")";
                    }
                }
                if ((!String.IsNullOrEmpty(Collation)) && (!IsUserDefinedType))
                {
                    sql += " COLLATE " + Collation;
                }
                if (IsIdentity)
                {
                    sql += " IDENTITY (" + IdentitySeed.ToString(CultureInfo.InvariantCulture) + "," + IdentityIncrement.ToString(CultureInfo.InvariantCulture) + ")";
                }
                if (IsIdentityForReplication)
                {
                    sql += " NOT FOR REPLICATION";
                }
                if (IsSparse)
                {
                    sql += " SPARSE";
                }
                if (IsFileStream)
                {
                    sql += " FILESTREAM";
                }
                if (IsNullable)
                {
                    sql += " NULL";
                }
                else
                {
                    sql += " NOT NULL";
                }
                if (IsRowGuid)
                {
                    sql += " ROWGUIDCOL";
                }
            }
            else
            {
                sql += "AS " + ComputedFormula;
                if (IsPersisted)
                {
                    sql += " PERSISTED";
                }
            }
            if ((sqlConstraint) && (DefaultConstraint != null))
            {
                if (DefaultConstraint.Status != Enums.ObjectStatusType.DropStatus)
                {
                    sql += " " + DefaultConstraint.ToSql().Replace("\t", "").Trim();
                }
            }
            return(sql);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="T:PrimaryKeyAttribute"/> class with the specified parameters.
 /// </summary>
 /// <param name="name">Name of the database primary key column.</param>
 /// <param name="managed">A <see langword="true" /> value indicates that the primary key should be
 /// defined as a <see cref="F:FieldType.ManagedPrimaryKey"/>.</param>
 public PrimaryKeyAttribute( string name, IdentityIncrement increment, object unsavedValue )
     : base(name)
 {
     this.UnsavedValue = unsavedValue;
     this.MappingType = increment == IdentityIncrement.Manual ?
         FieldMappingType.ManagedPrimaryKey : FieldMappingType.PrimaryKey;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="T:PrimaryKeyAttribute"/> class with the specified parameters.
 /// </summary>
 /// <param name="name">Name of the database primary key column.</param>
 /// <param name="managed">A <see langword="true" /> value indicates that the primary key should be
 /// defined as a <see cref="F:FieldType.ManagedPrimaryKey"/>.</param>
 public PrimaryKeyAttribute( string name, IdentityIncrement increment )
     : base(name)
 {
     this.MappingType = increment == IdentityIncrement.Manual ?
         FieldMappingType.ManagedPrimaryKey : FieldMappingType.PrimaryKey;
 }