If I look into our business objects we have two types of System.DateTime properties. One part of them are "Nullable" and "Source Nullable", the others are not nullable. The generated DataRow classes for the former ones contain raw System.Object properties:
/// <summary>Gets or sets the ActivityDate.</summary>
[DBDataType(typeof(System.DateTime))]
public virtual Object ActivityDate {
get {
Object result_;
if (GetInterceptor<Object>("ActivityDate", GetActivityDateImpl, out result_)) return result_;
return GetActivityDateImpl();
}
set {
if (!SetInterceptor<Object>("ActivityDate", value, SetActivityDateImpl)) {
SetActivityDateImpl(value);
}
}
}
private Object GetActivityDateImpl() {
return GetColumnValue(ActivityDateColumn, typeof(System.DateTime), true);
}
private void SetActivityDateImpl(Object value) {
SetColumnValue(ActivityDateColumn, value);
}
while the latter ones are typed:
/// <summary>Gets or sets the DeletedDateTime.</summary>
[DBDataType(typeof(System.DateTime))]
public virtual System.DateTime DeletedDateTime {
get {
System.DateTime result_;
if (GetInterceptor<System.DateTime>("DeletedDateTime", GetDeletedDateTimeImpl, out result_)) return result_;
return GetDeletedDateTimeImpl();
}
set {
if (!SetInterceptor<System.DateTime>("DeletedDateTime", value, SetDeletedDateTimeImpl)) {
SetDeletedDateTimeImpl(value);
}
}
}
private System.DateTime GetDeletedDateTimeImpl() {
return (System.DateTime) GetColumnValue(DeletedDateTimeColumn, typeof(System.DateTime), false);
}
private void SetDeletedDateTimeImpl(System.DateTime value) {
SetColumnValue(DeletedDateTimeColumn, value);
}
All these are generated. As far as I know the reason for this is that in early version of .NET there weren't nullable types, and DateTime is a value type. Nowadays if we create a new solution and new business objects if we map a DateTime column which is nullable in the DB, then IdeaBlade generates nullable C# datetime (using the Nullable<System.DateTime> notation AFAIK). Same with othe value types, a nullable integer in the DB will be mapped to Nullable<Int32>. However, our existing solution keeps using the old methods, RAW object types. Our big solution used .NET 3.5 for a while, and now we use .NET 4.0. So we could happily take advantage of nullable types in C#.
My questions: 1. Is there a switch somewhere, which could trigger IdeaBlade ORM mapper to use the Nullable<> notation in our existing solution? 2. Or can I mark/trigger certain fields in the ORM Relationship Mapper tool so they get regenerated into Nullable<System.DateTime>? (This way I could "fix" the raw objects to become System.DateTime).
|