Closed mrreddevil2412 closed 8 months ago
This is parameterized, should not report errors, you see if the system is adjusted
Maybe the data type is wrong
You can test this with a 2-field table
I try CreateTime and NgayTao You can see in picture If no insert NgayTao => success true
NgayTao dataType DateTime CreateTime same DataType
The first i see this bug
`[SugarTable("CC_DangKy")] public class CC_DangKy_Entity { [SugarColumn(IsPrimaryKey = true, IsNullable = false)] public long Id { get; set; }
[SugarColumn(IsNullable = false)]
public int? NamThang { get; set; }
public DateTime? Ngay { get; set; }
[SugarColumn(IsNullable = false)]
public long? EmployeeId { get; set; }
[SugarColumn(IsNullable = true, ColumnDataType = "varchar(50)")]
public string? Ca1 { get; set; }
[SugarColumn(IsNullable = true, ColumnDataType = "varchar(50)")]
public string? Ca2 { get; set; }
[SugarColumn(IsNullable = true, ColumnDataType = "varchar(50)")]
public string? Ca3 { get; set; }
[SugarColumn(IsNullable = true)]
public int? VanPhong { get; set; }
[SugarColumn(IsNullable = true, ColumnDataType = "nvarchar(500)")]
public string? CungDuong { get; set; }
[SugarColumn(IsNullable = true, ColumnDataType = "varchar(20)")]
public string? LoaiPhep { get; set; }
[SugarColumn(IsNullable = true, ColumnDataType = "nvarchar(500)")]
public string? LyDo { get; set; }
/// <summary>
/// Nghỉ từ giờ
/// </summary>
[SugarColumn(IsNullable = true, ColumnDataType = "Time")]
public TimeSpan? TuGio { get; set; }
/// <summary>
/// Nghỉ đến giờ
/// </summary>
[SugarColumn(IsNullable = true, ColumnDataType = "Time")]
public TimeSpan? DenGio { get; set; }
/// <summary>
/// Số giờ nghỉ
/// </summary>
[SugarColumn(IsNullable = true, ColumnDataType = "float")]
public TimeSpan? SoGio { get; set; }
[SugarColumn(IsNullable = true,ColumnDataType ="datetime")]
public DateTime NgayTao { get; set; }
[SugarColumn(ColumnDataType = "tinyint")]
public int? TrangThai { get; set; }
/// <summary>
/// Id người duyệt
/// </summary>
public long? NguoiDuyet1 { get; set; }
[SugarColumn(IsIgnore = true)]
[Navigate(NavigateType.OneToOne, nameof(NguoiDuyet1))]
public SysAccountInfoEntity? AccNguoiDuyet1 { get; set; }
public DateTime? Duyet1Ngay { get; set; }
public long? NguoiDuyet2 { get; set; }
[SugarColumn(IsIgnore = true)]
[Navigate(NavigateType.OneToOne, nameof(Duyet2Ngay))]
public SysAccountInfoEntity? AccNguoiDuyet2 { get; set; }
public DateTime? Duyet2Ngay { get; set; }
[SugarColumn(IsNullable = true, ColumnDataType = "nvarchar(500)")]
public string PhanHoi { get; set; }
[SugarColumn(IsNullable = true)]
public DateTime CreateTime { get; set; }
}`
This class Entity
[SugarColumn(IsNullable = true, ColumnDataType = "float")] public TimeSpan? SoGio { get; set; }
Change to
[SugarColumn(IsNullable = true, ColumnDataType = "time")] public TimeSpan? SoGio { get; set; }
Change the database, too
oh, it's worked :)) many thank bro!
[ERROR Message]: Operand type clash: time is incompatible with float [TYPE]: SqlException [ERROR INFO]: Operand type clash: time is incompatible with float [ERROR LINE]: at Microsoft.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
Insert Filed "@NgayTao" ='2024/01/16 12:19:22' When Excute in SqlServer 2019 => "@NgayTao" ='2024/01/1612:19:22'