Christophe lavoye
2018-02-27 15:13:19 UTC
I have a problem comparing DateTime and Timestamp in between my C# .NET
project and my database PostgreSQL (mapping with NHbernate).
Basically, i have a table with a column MY_COLUMN typed as "timestamp
without timezone"
In this one i can store value with milliseconds precision.
I have a stored function count_request(id, timestamp without time zone)
which compare the parameter timestamp without time zone with MY_COLUMN
I'm using EntityDevelopper to generate the NHibernate Mapping betwwen my
.NET project and my data base
MY_COLUMN is declared as :
<property name="RequestIn" type="Timestamp" p1:nullable="true" p1:ValidateRequired="false" p1:Guid="xxx">
<column name="request_in" not-null="false" sql-type="timestamp" p1:unicode="false" /></property>
the query is declared as..
<sql-query name="CountUserRequest" p1:procedure="public.count_user_request" callable="true" p1:Guid="xxx"><return-scalar column="return_value" type="Int64" /><query-param name="date_delta_t" p1:source="date_delta_t" p1:server-type="timestamp without time zone" type="Timestamp" /><query-param name="user_id" p1:source="user_id" p1:server-type="uuid" type="Guid" />select public.count_user_request(:date_delta_t, :user_id) as return_value</sql-query>
The generated C# method is
/// <summary>
/// There are no comments for CountUserRequest in the schema.
/// </summary>
public System.Nullable<long> CountUserRequest(System.Nullable<System.DateTime> date_delta_t, System.Nullable<System.Guid> user_id)
{
NHibernate.IQuery query = session.GetNamedQuery(@"CountUserRequest");
query.SetParameter(@"date_delta_t", date_delta_t);
query.SetParameter(@"user_id", user_id);
return ((System.Nullable<long>)(query.UniqueResult()));
}
When i try to call my function with a DateTime with milliseconds accuracy
it's like this information is lost and i can't be so accurate.
I can resolve my problem if i give the Date as string and then make a cast
like
'2018-02-13 13:43:08.200'::timestamp without time zone
But i don't understand why i cannot use directly the first method.
project and my database PostgreSQL (mapping with NHbernate).
Basically, i have a table with a column MY_COLUMN typed as "timestamp
without timezone"
In this one i can store value with milliseconds precision.
I have a stored function count_request(id, timestamp without time zone)
which compare the parameter timestamp without time zone with MY_COLUMN
I'm using EntityDevelopper to generate the NHibernate Mapping betwwen my
.NET project and my data base
MY_COLUMN is declared as :
<property name="RequestIn" type="Timestamp" p1:nullable="true" p1:ValidateRequired="false" p1:Guid="xxx">
<column name="request_in" not-null="false" sql-type="timestamp" p1:unicode="false" /></property>
the query is declared as..
<sql-query name="CountUserRequest" p1:procedure="public.count_user_request" callable="true" p1:Guid="xxx"><return-scalar column="return_value" type="Int64" /><query-param name="date_delta_t" p1:source="date_delta_t" p1:server-type="timestamp without time zone" type="Timestamp" /><query-param name="user_id" p1:source="user_id" p1:server-type="uuid" type="Guid" />select public.count_user_request(:date_delta_t, :user_id) as return_value</sql-query>
The generated C# method is
/// <summary>
/// There are no comments for CountUserRequest in the schema.
/// </summary>
public System.Nullable<long> CountUserRequest(System.Nullable<System.DateTime> date_delta_t, System.Nullable<System.Guid> user_id)
{
NHibernate.IQuery query = session.GetNamedQuery(@"CountUserRequest");
query.SetParameter(@"date_delta_t", date_delta_t);
query.SetParameter(@"user_id", user_id);
return ((System.Nullable<long>)(query.UniqueResult()));
}
When i try to call my function with a DateTime with milliseconds accuracy
it's like this information is lost and i can't be so accurate.
I can resolve my problem if i give the Date as string and then make a cast
like
'2018-02-13 13:43:08.200'::timestamp without time zone
But i don't understand why i cannot use directly the first method.
--
You received this message because you are subscribed to the Google Groups "nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nhusers+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nhusers+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/d/optout.