Just like I said, it is a JetDriver problem. I think because string
representation of date value contains culture specific AM / PM
designator (ب.ض and ق.ض) Jet engine can not accept it as a valid date
value. This is the first exception that is thrown in
NHibernate.Loader.Loader.GetResultSet :

Data type mismatch in criteria expression.

   at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling
(OleDbHResult hr)
   at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult
(tagDBPARAMS dbParams, Object& executeResult)
   at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object&
executeResult)
   at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior
behavior, Object& executeResult)
   at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal
(CommandBehavior behavior, String method)
   at System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior
behavior)
   at System.Data.OleDb.OleDbCommand.ExecuteReader()
   at
NHibernate.JetDriver.JetDbCommand.System.Data.IDbCommand.ExecuteReader
()
   at NHibernate.AdoNet.AbstractBatcher.ExecuteReader(IDbCommand cmd)
   at NHibernate.Loader.Loader.GetResultSet(IDbCommand st, Boolean
autoDiscoverTypes, Boolean callable, RowSelection selection,
ISessionImplementor session)

The problem is that in JetDbCommand, parameters of type DateTime are
specifically converted to string
(NHibernate.JetDriver.JetDbCommand.CheckParameters line 89) using
ToString("yyyy/MM/dd HH:mm:ss") method, but without specifying
Invariant Culture. I've fixed the bug and will create a task in
NHContrib to attach the patch.

further info here : http://blog.hightech.ir/2009/05/nhibernate-and-datetime.html

Best Regards,
Hadi

On May 21, 8:53 am, Hadi Eskandari <[email protected]> wrote:
> hmmm....Im trying to narrow it down, because, I'm running the build
> from the trunk, and I'm using Jet driver (NHContrib) and Linq (also on
> contrib). My first insight is that it might be a Jet driver issue.
> I'll update once I find exactly where this happens.
>
> On May 20, 5:49 pm, Fabio Maulo <[email protected]> wrote:
>
> > Where you having the problem ?Using NHibernate.Linq (on contrib),
> > CriteriaAPI direct, FNH ?
>
> > 2009/5/20 Hadi Eskandari <[email protected]>
>
> > > Hello,
>
> > > I'm using NHibernate with Fluent API on a WPF application. Now I've
> > > localized my application, and set the UICulture and Culture of the
> > > running thread to my specific culture (fa-ir) to get the underlying
> > > functionalities know about the application's culture. Now when
> > > querying data with NHibernate, there is a problem when DateTime
> > > instances are being converted to string (by nhibernate criteria). It
> > > seems to me that, ToString representation of the date objects are
> > > irrelevant, and invariant culture should be used to convert dates to
> > > strings before passing the criteria to the execution engine:
>
> > > this is wrong (Current) : var value = dateCriteria.ToString();
> > > should be this : var value = dateCriteria.ToString
> > > (CultureInfo.Invariant);
>
> > > anyone has this problem? How can I fix this, is this a bug, or there's
> > > something I'm missing here? Here's my query:
>
> > >      var todayStart = new DateTime(DateTime.Today.Year,
> > > DateTime.Today.Month, DateTime.Today.Day, 0, 0, 0,
> > > CultureHelper.DefaultCalendar); // Invariant Culture's calendar
> > > (gregorian)
> > >      var todayEnd = new DateTime(DateTime.Today.Year,
> > > DateTime.Today.Month, DateTime.Today.Day, 23, 59, 59,
> > > CultureHelper.DefaultCalendar);  // Invariant Culture's calendar
> > > (gregorian)
>
> > >      var queryable = UnitOfWork.CurrentSession.Linq<Purchase>();
> > >      var query = from sales in queryable
> > >                       where sales.PurchaseDate >= todayStart &&
> > > sales.PurchaseDate <= todayEnd
> > >                       select sales;
>
> > >      queryable.Expand("Purchaser");
> > >      queryable.Expand("Product");
>
> > >      return query.ToList();
>
> > --
> > Fabio Maulo
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to