Exemplo n.º 1
0
        /// <summary>
        /// Constructs a DmColumn object based on a DmColumnSurrogate object.
        /// </summary>
        public DmColumn ConvertToDmColumn()
        {
            DmColumn dmColumn = DmColumn.CreateColumn(this.ColumnName, DmUtils.GetTypeFromAssemblyQualifiedName(this.DataType));

            dmColumn.dbTypeAllowed = this.dbTypeAllowed;
            if (dmColumn.dbTypeAllowed)
            {
                dmColumn.DbType = (DbType)this.DbType;
            }

            dmColumn.AllowDBNull        = this.AllowDBNull;
            dmColumn.IsReadOnly         = this.IsReadOnly;
            dmColumn.MaxLength          = this.MaxLength;
            dmColumn.IsAutoIncrement    = this.IsAutoIncrement;
            dmColumn.Precision          = this.Precision;
            dmColumn.PrecisionSpecified = this.PrecisionSpecified;
            dmColumn.Scale            = this.Scale;
            dmColumn.ScaleSpecified   = this.ScaleSpecified;
            dmColumn.IsUnique         = this.IsUnique;
            dmColumn.IsUnicode        = this.IsUnicode;
            dmColumn.IsCompute        = this.IsCompute;
            dmColumn.IsUnsigned       = this.IsUnsigned;
            dmColumn.OriginalDbType   = this.OriginalDbType;
            dmColumn.OriginalTypeName = this.OriginalTypeName;
            dmColumn.SetOrdinal(this.Ordinal);

            return(dmColumn);
        }
Exemplo n.º 2
0
        public void DmColumn_SetOrdinal()
        {
            var tbl = new DmTable("ServiceTickets");

            var id = new DmColumn <Guid>("ServiceTicketID");

            tbl.Columns.Add(id);
            var key = new DmKey(new DmColumn[] { id });

            tbl.PrimaryKey = key;

            var titleColumn = new DmColumn <string>("Title");

            tbl.Columns.Add(titleColumn);
            var sv = new DmColumn <int>("StatusValue");

            tbl.Columns.Add(sv);
            var opened = new DmColumn <DateTime>("Opened");

            tbl.Columns.Add(opened);
            var closedColumn = DmColumn.CreateColumn("Closed", typeof(DateTime));

            tbl.Columns.Add(closedColumn);

            Assert.Equal(0, id.Ordinal);
            Assert.Equal(1, titleColumn.Ordinal);
            Assert.Equal(2, sv.Ordinal);
            Assert.Equal(3, opened.Ordinal);
            Assert.Equal(4, closedColumn.Ordinal);

            sv.SetOrdinal(1);

            Assert.Equal(0, id.Ordinal);
            Assert.Equal(1, sv.Ordinal);
            Assert.Equal(2, titleColumn.Ordinal);
            Assert.Equal(3, opened.Ordinal);
            Assert.Equal(4, closedColumn.Ordinal);

            closedColumn.SetOrdinal(0);

            Assert.Equal(0, closedColumn.Ordinal);
            Assert.Equal(1, id.Ordinal);
            Assert.Equal(2, sv.Ordinal);
            Assert.Equal(3, titleColumn.Ordinal);
            Assert.Equal(4, opened.Ordinal);
        }