SqlServer中的bool类型就是bit,赋值的时候赋值0或1即可,同时数据库在编辑状态下会自动与字符串常亮True和False替换。
使用SqlSugar的时候设置bit类型,如下代码IsImportant 和 IsFinish字段就是bool类型的设置方法 :
[SugarTable"Task",tableDescription:"My to do things")] public class Task { [SugarColumnIsPrimaryKey =true,ColumnDataType ="varchar255)")] public string ID { get; set; } [SugarColumnColumnDataType = "nvarchar255)")] public string Title { get; set; } [SugarColumnColumnDataType = "nvarchar255)",IsNullable =true)] public string Description { get; set; } [SugarColumnColumnDataType = "datetime")] public DateTime StartTime { get; set; } [SugarColumnColumnDataType = "datetime",IsNullable =true)] public DateTime? Deadline { get; set; } [SugarColumnColumnDataType = "bit")] public bool IsImportant { get; set; } [SugarColumnColumnDataType = "bit")] public bool IsFinish { get; set; } }
PS:注意不要设置成varchar)类型了,否则ORM框架映射可能就会出现问题