MicroLite-ORM / MicroLite

MicroLite ORM framework
microliteorm.wordpress.com
Apache License 2.0
85 stars 24 forks source link

Setting DbType via Column Attribute results in a compilation error #450

Closed ma499 closed 8 years ago

ma499 commented 8 years ago

I'm trying to take advantage of the feature #364 which allows configuration of DBType using a column attribute.

It doesn't seem to work. When I write something like this: [Column("table_datefrom", DbType.DateTime)]

I get the following compilation error: An attribute argument must be a constant expression, typeof expression or array creation expression of an attribute parameter type

How is this supposed to work? Apologies if I've missed something in the documentation.

TrevorPilley commented 8 years ago

It seems it doesn't work, I thought it should since the DbType enum is just a bunch of numbers under the hood... Looks like that'll have to be removed although it might be that no-one else has ever tried to use it.

The DbType is inferred from the property type anyway so you'd only actually need to set it under weird circumstances. You can see the default mapping here the default for DateTime will change to DbType.DateTime2 in MicroLite 6.3

ma499 commented 8 years ago

Yes, I'm doing something wierd :) I have a my model class using a custom type that has an implicit operator conversion to/from DateTime (and internally stores a private DateTime)... (The type is serialisable to a special format.)

Shall try the TypeConvertor approach.