ServiceStack/ServiceStack.OrmLite — Issue #8: Passing DateTimes to SqlServer
Author: Haplois
Created: 2012-01-24 04:24:36+00:00
State: open

When dateformat is not ymd, OrmLite can't pass DateTime values in query...

for example:
cmd.Insert(sepet);

produces sql statement:
INSERT INTO "Sepet" ("UserId","FaturaAdresiId","GonderiAdresiId","SepetDurumu","OdemeTuru","OdendiMi","OlusturmaTarihi","OdemeTarihi") VALUES (CAST('1788d4fa-f2ae-4146-8344-177ed84cecbd' AS UNIQUEIDENTIFIER),1,1,1,2,0,'2012-01-24 06:17:35.363',NULL);

Because we passing datetime as varchar, when the language of db is other then english, it throws an sql exception.

TO fix this,
I neet to run this befor the actual query

cmd.CommandText = "SET DATEFORMAT YMD";
cmd.ExecuteNonQuery();

----------------------
You can use ISO 8601 (YYYYMMDDThh:mm:ss[.mmm]) standard or unseperated value (YYYYMMDD hh:mm:ss[.mmm]) to pass datetime to fix this.