This website is intended as archive for old content and forums.
Please visit http://opf3.codeplex.com for the project's new website.

General Discussion

FORUM TOPIC

What is Opf3? Why is Opf3? How is Opf3? All these burning questions and issues discussed here.

RSS
Marcelo Nicolet
Posted on the 01/10/08 6:50 PM
Strange exception(1)
Reply Quote
 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

Christian Liensberger [Moderator]
Posted on the 01/11/08 10:10 AM
RE: Strange exception(1)
Reply Quote
 Hi,

the value that you return from the database doesn't seem to be castable to a DateTime!

I hope this helps.

Christian

All times are in GMT.