Esempio n. 1
0
        private void Initialize()
        {
            ActiveTableAttribute attribute = Attribute.GetCustomAttribute(dataRecordType, typeof(ActiveTableAttribute)) as ActiveTableAttribute;

            if (attribute == null)
            {
                Datasource = string.Empty;
                Owner      = "dbo";
                Name       = dataRecordType.Name;
                IsReadOnly = false;
                return;
            }

            Datasource = string.Empty;
            Owner      = attribute.Owner;
            Name       = attribute.Name;
            IsReadOnly = attribute.ReadOnly;

            Columns = new QueryableColumns();
            foreach (QueryColumn column in TableColumnData.CreateColumns(this, dataRecordType))
            {
                Columns.Add(column);
            }

            PrimaryKey       = new PrimaryKeys(this);
            IdentityColumn   = PrimaryKey.GetIdentityColumn();
            DeletedColumn    = attribute.DeletedColumn == null ? null : Columns.FindColumn(attribute.DeletedColumn);
            CreatedOnColumn  = attribute.CreatedOnColumn == null ? null : Columns.FindColumn(attribute.CreatedOnColumn);
            ModifiedOnColumn = attribute.ModifiedOnColumn == null ? null : Columns.FindColumn(attribute.ModifiedOnColumn);
            CreatedByColumn  = attribute.CreatedByColumn == null ? null : Columns.FindColumn(attribute.CreatedByColumn);
            ModifiedByColumn = attribute.ModifiedByColumn == null ? null : Columns.FindColumn(attribute.ModifiedByColumn);
        }
Esempio n. 2
0
        public void FromExternalBaseClassTypeOf()
        {
            // Using typeof() on a base class does not retrieve the metadata for a derived class.
            // typeof() only works on the actual decorated class. The GetType() instance method must be used
            // in all other instances as it is the only way the CLR knows the class hierarchy.
            ActiveTableAttribute attribute = (ActiveTableAttribute)Attribute.GetCustomAttribute(typeof(BaseClass), typeof(ActiveTableAttribute));

            Assert.IsNull(attribute);
        }
Esempio n. 3
0
        public void FromExternalDecoratedClassTypeOf()
        {
            ActiveTableAttribute attribute = (ActiveTableAttribute)Attribute.GetCustomAttribute(typeof(Derived), typeof(ActiveTableAttribute));

            Assert.IsNotNull(attribute);
            Assert.AreEqual("Sales", attribute.Owner);
            Assert.AreEqual("Customer", attribute.Name);
            Assert.AreEqual("CustomerID", attribute.KeyColumn);
            Assert.AreEqual("ModifiedDate", attribute.ModifiedOnColumn);
        }
Esempio n. 4
0
        public void FromExternalBaseClassGetType()
        {
            BaseClass            baseClass = new Derived();
            ActiveTableAttribute attribute = (ActiveTableAttribute)Attribute.GetCustomAttribute(baseClass.GetType(), typeof(ActiveTableAttribute));

            Assert.IsNotNull(attribute);
            Assert.AreEqual("Sales", attribute.Owner);
            Assert.AreEqual("Customer", attribute.Name);
            Assert.AreEqual("CustomerID", attribute.KeyColumn);
            Assert.AreEqual("ModifiedDate", attribute.ModifiedOnColumn);
        }
Esempio n. 5
0
        public void FromInternalDerivedClassBaseReference()
        {
            // This works because we are working on an instance that the CLR knows the class hierarchy of.
            BaseClass            baseClass = new Derived();
            ActiveTableAttribute attribute = baseClass.GetAttribute();

            Assert.IsNotNull(attribute);
            Assert.AreEqual("Sales", attribute.Owner);
            Assert.AreEqual("Customer", attribute.Name);
            Assert.AreEqual("CustomerID", attribute.KeyColumn);
            Assert.AreEqual("ModifiedDate", attribute.ModifiedOnColumn);
        }
Esempio n. 6
0
            public ActiveTableAttribute GetAttribute()
            {
                ActiveTableAttribute attribute = (ActiveTableAttribute)Attribute.GetCustomAttribute(GetType(), typeof(ActiveTableAttribute));

                return(attribute);
            }