So, I am creating an application that collects a ton of code generation with C # and VB outputs (depending on the project settings).
I have a CodeTemplateEngine, with two derived classes VBTemplateEngine and CSharpTemplateEngine. This question is about creating property-based column signatures in a database table. Using the IDataReader GetSchemaTable method, I collect the CLR type of the column, for example, "System.Int32", and whether it is IsNullable. However, I would like to keep the code simple and instead of a property that looks like this:
public System.Int32? SomeIntegerColumn { get; set; }
or
public Nullable<System.Int32> SomeIntegerColumn { get; set; },
where the property type will be resolved using this function (from my VBTemplateEngine),
public override string ResolveCLRType(bool? isNullable, string runtimeType) { Type type = TypeUtils.ResolveType(runtimeType); if (isNullable.HasValue && isNullable.Value == true && type.IsValueType) { return "System.Nullable(Of " + type.FullName + ")";
I would like to create a simpler property. I hate the idea of building a type string from nothing, and I would prefer something like:
public int? SomeIntegerColumn { get; set; }
Is there anything built in anywhere, for example, in the VBCodeProvider or CSharpCodeProvider classes that somehow take care of this for me?
Or is there a way to get an alias of type int? from a type string, such as System.Nullable'1[System.Int32] ?
Thanks!
UPDATE:
found something to do this, but I'm still afraid of this type of matching full type names with their aliases.