| | Strange exception (1)
I have to very similar queries
DateTime from = DateTime.Parse( "2007-12-01" );
string hqs = " Tstamp >= {0} SortBy Tstamp desc "; ObjectQuery<Clone> clQuery = new ObjectQuery<Clone>(hqs, from); ObjectSet<Clone> clones = hidctx.GetObjectSet<Clone>(clQuery, 10);
and
string rqs = " ( Remoteterminal[Id = 141] Or Remoteterminal[Id = 140] ) " + " And Datetime >= {0} And Checked = 0 SortBy Datetime asc "; ObjectQuery<Tsdreport> tsdQuery = new ObjectQuery<Tsdreport>( rqs, from ); ObjectSet<Tsdreport> reps = repctx.GetObjectSet<Tsdreport>(tsdQuery, 10);
The first one, throws an exception on GetObjectSet<Clone>(clQuery, 10); The exception and stack trace follows
System.InvalidCastException was unhandled Message="Object must implement IConvertible." Source="mscorlib" StackTrace: at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider) at System.Convert.ChangeType(Object value, Type conversionType) at Chili.Opf3.Mapping.DynamicPopulateHelperMetaInfo.SetValue(Object obj, Object value) at Chili.Opf3.Storages.ObjectDataAdapter.FillMember(Object obj, IMemberInfo info, Object value) at Chili.Opf3.Storages.ObjectDataAdapter.FillObject(Object obj, IDataRecord dataRecord, ObjectInfo objectInfo, ObjectReaderSchema schema) at Chili.Opf3.Storages.StorageObjectReader`1.ReadNewObject(Type type) at Chili.Opf3.Storages.StorageObjectReader`1.InternalRead(Int32 step) at Chili.Opf3.ObjectReader`1.Read(Int32 step) at Chili.Opf3.ObjectReader`1.MoveNext() at Chili.Opf3.ObjectSet`1.Load(ObjectContext context, IQuery query, Int32 amount) at Chili.Opf3.ObjectSet`1.Chili.Opf3.ICustomPersister.Load(ObjectContext context, IQuery query, Int32 amount) at Chili.Opf3.ObjectContext.GetObjectSet[T](IQuery query, Int32 amount) at rep_to_hidro.Program.Main(String[] args) in C:\Hidro\rep-to-hidro\rep-to-hidro.cs:line 35
Because initially the first query was only to sort the ObjectSet ( "SortBy Tstamp" ) I think this is a question with the DateTime props, which follows
[Persistent("CLONE")] public class Clone {
...........
private DateTime tstamp; ...........
[Field("TSTAMP")] public DateTime Tstamp { get { return tstamp; } set { tstamp = value; } } ............
and
[Persistent("TSDREPORT", PoolSize = 10)] public partial class Tsdreport { ............ private DateTime datetime; ............ [Field("DATETIME")] public DateTime Datetime { get { return datetime; } set { datetime = value; } }
Could you help me ? TIA Marcelo
|
| | Hi,
the value that you return from the database doesn't seem to be castable to a DateTime!
I hope this helps.
Christian
|