I'm doing some reflection on generated LINQ to SQL classes (i.e. DataContext). For each property (column) on a class (table) I'm getting the ColumnAttribute.DbType
value.
It can be various different values, here's some examples:
- Int NOT NULL
- Int
- VarChar(255)
- VarChar(255) NOT NULL
- Bit
... and so on.
If I wanted to parse these strings into seperate meaningful values, such as "DataType", "Nullable" and "MaxLength", what would the best approach be?
I don't need a full-on lexer/parser thingy or language interpreter, I don't think it's necessary to go after something like M. Other than some (horrible) specific manual parsing involving Substring
, what would you recommend?
Answers in C#, please - that's pretty much all I'm good for these days :)