6

How Can I map "timestamp with time zone" datatype from postgreSql to System.Data.DbType I need to pass parameter as it will go to the column which has "timestamp with time zone"

following is my code:

var pOrderDate = cmdOrder.CreateParameter();
pOrderDate.ParameterName = "OrderDate";
pOrderDate.DbType = System.Data.DbType.DateTime;
pOrderDate.Value = objOrder.OrderDate;
cmdOrder.Parameters.Add(pOrderDate);

Following line causes problem:

pOrderDate.DbType = System.Data.DbType.DateTime;
22
  • 9
    @Freelancer please speak English. Commented Apr 5, 2013 at 10:35
  • This is my c# code..I need to map through my program. Commented Apr 5, 2013 at 10:37
  • 1
    @Freelancer - if you not agree to use English in this forum - find other place for your converastion. Commented Apr 5, 2013 at 11:35
  • 1
    @Freelancer - blog.stackoverflow.com/2009/07/non-english-question-policy Commented Apr 5, 2013 at 11:49
  • 1
    let us continue this discussion in chat Commented Apr 5, 2013 at 12:29

1 Answer 1

2

Have you considered trying the DateTimeOffset class in .NET?

I'm unaware of how it maps to Postgres "DateTime with Timezone" type, but it has a 1:1 correlation with what I believe would be the MSSQL equivalent (also called DateTimeOffset).

Note that the naming here is quite poor - the type represents a DateTime + Offset, and not just the Offset itself.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.