dotnetcore / dotnetcore/FreeSql
Format datetime error
- Dominant language
- C#
- Stars
- 4.4k
- Forks
- 910
- PR merge metrics
- No merged PRs in 30d
Description
#### Problem description and reproducible code:
Format datetime error
```// Code C#
public class TableSample {
[Column(IsIdentity = false, IsPrimary = true)]
public int Id { get; set; }
public DateTime TimeStamp { get; set; }
}
var fsql= new FreeSql.FreeSqlBuilder()...
var formatDate = fsql.Ado.QuerySingle("SELECT r.date_format FROM master.sys.dm_exec_requests r WHERE r.session_id = @@SPID");
// formatDate = "dmy"
int id = 1;
var sql = fsqlSage.Update(id).Set(x => x.TimeStamp, DateTime.Today).ToSql();
// sql= "UPDATE [TableSample] SET [TimeStamp] = '**2024-07-30** 00:00:00.000' WHERE ([Id] = 1)"
// SqlException: convert varchar to datetime.
// correct: "UPDATE [TableSample] SET [TimeStamp] = '**30-07-2024** 00:00:00.000' WHERE ([Id] = 1)"
```
#### Database version
SQLEXPRESS 15.0.20000
#### Nuget
FreeSql.All 3.2.832
#### .net framework/.net core? y versión específica
.Net 8.0
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reproducing the generated UPDATE with SQL Server configured for the reported dmy date format, using the C# model and Update call shown in the issue. Trace how the SQL Server provider formats DateTime values; done means the update executes successfully under dmy and the reported conversion error has regression coverage.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, sql
- Domain
- database
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100