This question is locked. New answers and comments are not allowed.
This is something I constantly get reminded that I need.
After the introduction of sql type datetime2 support, not so much, but I still need to hack around to achieve desired result.
Basically, this is an attribute that can be applied to fields/properties to specify a different CLR Type than database type where no 1:1 mapping exist, but a simple (or complex for that matter) conversion can be performed.
This is best explained with a simple example:
The base class could be provided as part as OpenAcces and descendant Attribute classes implemented by developers to automatically convert values on load/persist/query operations.
The big advantage here is the ability to use LINQ on the market properties as the actual type:
Please let me know if none of this make sense.
Thanks
Pål
After the introduction of sql type datetime2 support, not so much, but I still need to hack around to achieve desired result.
Basically, this is an attribute that can be applied to fields/properties to specify a different CLR Type than database type where no 1:1 mapping exist, but a simple (or complex for that matter) conversion can be performed.
This is best explained with a simple example:
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]public abstract class TypeConverterAttribute<T1, T2> : Attribute { public abstract T2 ConvertTo(T1 item); public abstract T1 ConvertFrom(T2 item);}public class TypeToStringConverterAttribute : TypeConverterAttribute<Type, String> { public override String ConvertTo(Type item) { return item.FullName; } public override Type ConvertFrom(String item) { return Type.GetType(item); }}public class MyPersistentClass { [TypeToStringConverter] public Type Type { get; set; }}The base class could be provided as part as OpenAcces and descendant Attribute classes implemented by developers to automatically convert values on load/persist/query operations.
The big advantage here is the ability to use LINQ on the market properties as the actual type:
var query = from m in new List<MyPersistentClass>().AsQueryable() where m.Type == typeof(Exception) select m;Please let me know if none of this make sense.
Thanks
Pål