nhibernate - SQLite won't match C# DateTime retrieved from database -


I am trying to run some unit tests on my application using SQLite in memory, but I have a strange problem I have two questions:

I have the first question of the most recent price list for the price list list, and in the second code to get the most recent prices, DateTime is used The problem is the second query, any results

Any ideas on what might be going wrong in the background

  var effective = DbSession.Current.CreateCriteria. & Lt ;? ItemPrice & gt; () .SetProjection (Projections.Max ("Effective")) .add (Restrictions.Le ("Effective", workDate)) .CreateCriteria ("pricelist") .Add (Restrictions.Eq ("ListName", listname)) (Restrictions. AEC) (Add "Activated", true). Anikrass Result & lt; DateTime & gt; (); Return DbSession.Current.CreateCriteria & LT; ItemPrice & gt; () .Add (Restrictions.Eq ("Effective "Effective) .CreateCriteria (" pricelist ") .Add (Restrictions.Eq (" ListName ", listname)) .add (restriction .EQ (" active ", true)). LIST & lt; ItemPrice & gt; ();   

Result: Applying a custom IUserType end time to store the string as a string, and date time Add a well-known Automapping Conference to use it ( Included):

  class SQLiteDateTime: IUserType {#region IUserType member collects public items (object cache, object owner) {return cached;} public object lampc (object value) {var dt = ( DateTime) Return; New Date Time Return (DT. years, DT.Month, DT.DE, DT.HOR, DT.m., DT. seconds);} Public Object Disassemble {Return String.format ("{{ 0: yyyy '-' MM '-' DD 'HH': 'MM': 'SFF}}', value); } Public new bool equals (object x, object y) {return x.Equals (y); } Public inthecod (object x) {return x.GetHashCode (); } Public Bull Ismate Qualified {Return; }} Public Objects NullSafeGet (IDataReader RS, String [] Names, Object Owners) {String Datrustring = (string) NHibernateUtil.String.NullSafeGet (RS, name [0]); Date time result = DateTime.ParseExact (datostring, "yyyy '-' mm '-' dd '' hh ':' mm ':' ss.fff ', CultureInfo.InvariantCulture.DateTimeFormat); Return result; } Public Zero NullSafeSet (IDbCommand CMD, Object Value, Index Index) {if (value == null) {NHibernateUtil.String.NullSafeSet (cmd, null, index); Return; } Value = dysfunction (value); NHibernateUtil.String.NullSafeSet (CMD, Value, Index); } Change public object (object origin, object target, object owner) {return original; } Public Type Returned Type {{Receive Return Type (DateTime); }} Public NHibernate.SqlTypes.SqlType [] SqlTypes {get {var types = new SqlType [1]; Type [0] = new SqlType (DbType.String); Return type; }} #endregion}    

set a customType Try that timestamp for that column, I think the difference in whether or not to save the millisecond, is the difference.

Comments