float? BUG

This commit is contained in:
sunkaixuan
2018-11-26 00:13:18 +08:00
parent c9012a1d58
commit c03ce1e890
3 changed files with 40 additions and 8 deletions

View File

@@ -41,27 +41,43 @@ namespace OrmTest.BugTest
SqlFunc.Contains(u.HousePlace, keyword) || SqlFunc.Contains(u.UnitName, keyword) ||
SqlFunc.Contains(u.BuildName, keyword) || SqlFunc.IsNullOrEmpty(keyword)))
.GroupBy(ru => new { ru.RoomNumber, ru.RoomID })
.Select(ru => new
.Select(ru => new
{
RoomNumber = SqlFunc.AggregateMax(ru.RoomNumber),
CountRoomer = SqlFunc.AggregateCount(ru.RoomerName),
RoomID = SqlFunc.AggregateMax(ru.RoomID),
Owner = SqlFunc.Subqueryable<SubTable>().Where(r => r.RoomID == ru.RoomID && SqlFunc.Equals(r.RoomUserType, "业主") && SqlFunc.Equals(r.RoomUserType, "业主")).Select(s => s.RoomerName)
RoomNumber = SqlFunc.AggregateMax(ru.RoomNumber),
CountRoomer = SqlFunc.AggregateCount(ru.RoomerName),
RoomID = SqlFunc.AggregateMax(ru.RoomID),
Owner = SqlFunc.Subqueryable<SubTable>().Where(r => r.RoomID == ru.RoomID && SqlFunc.Equals(r.RoomUserType, "业主") && SqlFunc.Equals(r.RoomUserType, "业主")).Select(s => s.RoomerName)
}).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
{

View File

@@ -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);

View File

@@ -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))