Reputation: 292
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;
Upvotes: 6
Views: 3021
Reputation: 61
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.
Upvotes: 2