Exemple #1
0
 internal DataTableColumn(DataTableColumnAttribute attribute, PropertyInfo property)
 {
     _property   = property;
     _primaryKey = attribute.PrimaryKey;
     _columnName = attribute.ColumnName;
     if (string.IsNullOrWhiteSpace(_columnName))
     {
         _columnName = property.Name;
     }
     _typeName = attribute.DataType;
     if (string.IsNullOrWhiteSpace(_typeName))
     {
         _typeName = ConvertTypeName(property.PropertyType);
     }
 }
Exemple #2
0
        private static DataTableColumn[] ExtractDataColumns()
        {
            List <DataTableColumn> columns = new List <DataTableColumn>();

            PropertyInfo[] properties = typeof(T).GetProperties();
            foreach (PropertyInfo property in properties)
            {
                DataTableColumnAttribute attribute = property.GetCustomAttribute <DataTableColumnAttribute>();
                if (attribute != null)
                {
                    DataTableColumn column = new DataTableColumn(attribute, property);
                    columns.Add(column);
                }
            }
            return(columns.ToArray());
        }