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();

--~--~---------~--~----~------------~-------~--~----~
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