mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-20 02:29:39 +08:00
float? BUG
This commit is contained in:
@@ -50,18 +50,34 @@ SqlFunc.Contains(u.BuildName, keyword) || SqlFunc.IsNullOrEmpty(keyword)))
|
||||
}).OrderBy((r) => r.RoomNumber, type: OrderByType.Desc).ToPageListAsync(1, 2).Wait();
|
||||
|
||||
GetInstance().Updateable<Student>().UpdateColumns(it =>
|
||||
new Student() {
|
||||
new Student()
|
||||
{
|
||||
Name = "a".ToString(),
|
||||
CreateTime=DateTime.Now.AddDays(-1)
|
||||
CreateTime = DateTime.Now.AddDays(-1)
|
||||
|
||||
}
|
||||
).Where(it=>it.Id==1).ExecuteCommand();
|
||||
).Where(it => it.Id == 1).ExecuteCommand();
|
||||
|
||||
|
||||
var list = GetInstance().Queryable<Student, School>((st, sc) => new object[] {
|
||||
JoinType.Left,st.SchoolId==sc.Id&&st.CreateTime==DateTime.Now.AddDays(-1)
|
||||
})
|
||||
.Where(st => st.Name == "jack").ToList();
|
||||
|
||||
|
||||
GetInstance().Updateable<BugStudent>().Where(it => true).UpdateColumns(it => new BugStudent() { Float = 11 }).ExecuteCommand();
|
||||
var reslut= GetInstance().Queryable<BugStudent>().ToList();
|
||||
}
|
||||
|
||||
|
||||
[SugarTable("student")]
|
||||
public class BugStudent
|
||||
{
|
||||
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
|
||||
public int Id { get; set; }
|
||||
public string name { get; set; }
|
||||
public float? Float { get; set; }
|
||||
|
||||
}
|
||||
public class MainTable
|
||||
{
|
||||
|
@@ -53,6 +53,7 @@ namespace SqlSugar
|
||||
private static readonly MethodInfo getTime = typeof(IDataRecordExtensions).GetMethod("GetTime");
|
||||
private static readonly MethodInfo getConvertDecimal = typeof(IDataRecordExtensions).GetMethod("GetConvertDecimal");
|
||||
private static readonly MethodInfo getConvertDouble = typeof(IDataRecordExtensions).GetMethod("GetConvertDouble");
|
||||
private static readonly MethodInfo getConvertDoubleToFloat = typeof(IDataRecordExtensions).GetMethod("GetConvertDoubleToFloat");
|
||||
private static readonly MethodInfo getConvertGuid = typeof(IDataRecordExtensions).GetMethod("GetConvertGuid");
|
||||
private static readonly MethodInfo getConvertInt16 = typeof(IDataRecordExtensions).GetMethod("GetConvertInt16");
|
||||
private static readonly MethodInfo getConvertInt32 = typeof(IDataRecordExtensions).GetMethod("GetConvertInt32");
|
||||
@@ -265,6 +266,9 @@ namespace SqlSugar
|
||||
method = isNullableType ? getConvertDouble : getDouble;
|
||||
else
|
||||
method = isNullableType ? getConvertFloat : getFloat;
|
||||
if (dbTypeName == "float" && isNullableType && bindProperyTypeName == "single") {
|
||||
method = getConvertDoubleToFloat;
|
||||
}
|
||||
break;
|
||||
case CSharpDataType.Guid:
|
||||
CheckType(bind.GuidThrow, bindProperyTypeName, validPropertyName, propertyName);
|
||||
|
@@ -95,6 +95,18 @@ namespace SqlSugar
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public static float? GetConvertDoubleToFloat(this IDataRecord dr, int i)
|
||||
{
|
||||
if (dr.IsDBNull(i))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var result = dr.GetDouble(i);
|
||||
return Convert.ToSingle(result);
|
||||
}
|
||||
|
||||
|
||||
public static Guid? GetConvertGuid(this IDataRecord dr, int i)
|
||||
{
|
||||
if (dr.IsDBNull(i))
|
||||
|
Reference in New Issue
Block a user