// Returns a collection of properties (columns) for the type, each with attributes
        // for that table
        public override PropertyDescriptorCollection GetProperties()
        {
            PropertyDescriptorCollection originalCollection = base.GetProperties();

            bool customDescriptorsCreated = false;
            List <PropertyDescriptor> tempPropertyDescriptors = new List <PropertyDescriptor>();

            foreach (PropertyDescriptor propDescriptor in originalCollection)
            {
                PropertyInfo     propInfo    = Type.GetProperty(propDescriptor.Name, propDescriptor.PropertyType);
                List <Attribute> newMetadata = InMemoryMetadataManager.GetColumnAttributes(propInfo);
                if (newMetadata.Count > 0)
                {
                    tempPropertyDescriptors.Add(new PropertyDescriptorWrapper(propDescriptor, newMetadata.ToArray()));
                    customDescriptorsCreated = true;
                }
                else
                {
                    tempPropertyDescriptors.Add(propDescriptor);
                }
            }

            if (customDescriptorsCreated)
            {
                // only create a new collection if it is necessary
                return(new PropertyDescriptorCollection(tempPropertyDescriptors.ToArray(), true));
            }
            else
            {
                return(originalCollection);
            }
        }
        // Returns the collection of attributes for a given type (table)
        public override AttributeCollection GetAttributes()
        {
            AttributeCollection baseAttributes = base.GetAttributes();

            List <Attribute> extraAttributes = InMemoryMetadataManager.GetTableAttributes(Type);

            if (extraAttributes.Count != 0)
            {
                // only create a new collection if it is necessary
                return(AttributeCollection.FromExisting(baseAttributes, extraAttributes.ToArray()));
            }
            else
            {
                return(baseAttributes);
            }
        }