What's the actual data type of the column in question? I'm a bit confused by the question, because DATETIME is a SQL type completely separate from either an Epoch date or a string. "2012-09-22" is a string, not a date - it just happens to be a string that corresponds to an ISO date representation. These two datatypes are inherently incompatible without conversion logic.
If application (1) is serialising the [in memory] date in epoch format, then I'd expect an int column (or some variation of that) If application (2) is serialising the [in memory] date as a DATETIME, then the column is (by definition) a DATETIME If they're using the _same column_ then is it a (var)char or something like that? Coming back to the question, the NHibernate DateTime type is designed to work against a DATETIME column and has no idea what to make of an int. Personally, I'd suggest normalising the storage mechanism so that both applications use the same format; if that's completely impossible for some reason then you can write an IUserType which operates against a (var)char column and converts the value into a dotnet date by using a TryParse to int and assuming this in an epoch value, or if that fails then a TryParse to datetime. However, that's extremely fragile and error prone as the column can hold meaningless values. There's also the question of how application (1) is going to handle an ISO-formatted date when it's expecting an epoch value? Pete From: [email protected] [mailto:[email protected]] On Behalf Of Anthony Presley Sent: 20 September 2012 04:07 To: [email protected] Subject: [nhusers] NHibernate and Epoch's We have a database table which has the following set up: CREATE TABLE attendance_block (start_date DATETIME, end_date DATETIME); One application writes to this database and stores the dates as Unix Epoch dates, which it uses in its program logic. Another program (which we can change and have the source code to) uses NHibernate DateTime types, and stores data in the database in "regular" datetime formats, ie "2012-09-22". NHibernate throws a royal fit if we use DateTime types and there are Epoch dates in it. Is there a way to make NHibernate more flexible - ie, load the date regardless of whether it's in Epoch or "regular" format? -- Anthony -- You received this message because you are subscribed to the Google Groups "nhusers" group. To view this discussion on the web visit https://groups.google.com/d/msg/nhusers/-/dWKVo7kKw7oJ. 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. -- 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.
