I have a user-defined structure for Time which wraps a DateTime field. It behaves properly i.e. it builds, reads and writes to the database. VEnhance throws an error when I declare a Nullable Time, which I would expect to work, can anyone guide me?
C:\Dev\Products\Testbed\Deliverables\Domain\obj\Debug\MSW.MAPS.Testbed.Domain.dll(-1,-1): OpenAccess Enhancer error 0: Unsupported field-type 'System.Nullable`1[MSW.Time]' found for field 'aNullableTime' of class 'MSW.MAPS.Testbed.Domain.CountryExample'. (Unsupported value type 'System.Nullable`1[[MSW.Time, MSW.MAPS.Framework, Version=2.3.3366.15159, Culture=neutral, PublicKeyToken=null]]'. The type is not marked as [Persistent].)
Here's the usage of Time, (deliberately trimmed down to highlight the point):
using
Telerik.OpenAccess;
namespace
MSW.MAPS.Testbed.Domain {
[
Persistent]
public partial class CountryExample {
private Time someTime;
private Time? aNullableTime;
internal CountryExample() { }
[
FieldAlias("someTime")]
public Time SomeTime {
get { return someTime; }
set { someTime = value; }
}
[
FieldAlias("aNullableTime")]
public Time? ANullableTime {
get { return aNullableTime; }
set { aNullableTime = value; }
}
}
}
Here's the source code for Time:
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text.RegularExpressions;
using Telerik.OpenAccess;
namespace
MSW {
[Serializable]
[
Persistent]
public struct Time : IFormattable {
private DateTime data;
public Time(int hour, int minute, int second) : this(new DateTime(1900, 1, 1, hour, minute, second)) {}
public Time(DateTime dateTime) {data = dateTime;}
public int Hour { get { return Data.Hour; } }
public int Minute { get { return Data.Minute; } }
public int Second { get { return Data.Second; } }
//Allows OpenAccess to compile - do not use, value-types should be immutable.
internal DateTime Data {
get { return data; }
set { data = value; }
}
public override string ToString() {return Data.ToLongTimeString();}
public string ToString(string format, IFormatProvider formatProvider) { return Data.ToString(format, formatProvider); }
public string ToXmlString() { return Data.ToString(Second != 0 ? "HH:mm:ss" : "HH:mm"); }
public override bool Equals(object obj) {
if (obj == null) return false;
if (this.GetType() != obj.GetType()) return false;
return Data.Equals(((Time)obj).Data);
}
public override int GetHashCode() { return Data.GetHashCode(); }
}
}
TIA,
Adam