mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-22 20:13:41 +08:00
Synchronization code
This commit is contained in:
@@ -695,10 +695,22 @@ namespace SqlSugar
|
||||
public virtual Task<DataSet> GetDataSetAllAsync(string sql, params SugarParameter[] parameters)
|
||||
{
|
||||
Async();
|
||||
|
||||
//False asynchrony . No Support DataSet
|
||||
return Task.Run(() => {
|
||||
return GetDataSetAll(sql, parameters);
|
||||
});
|
||||
if (CancellationToken == null)
|
||||
{
|
||||
return Task.Run(() =>
|
||||
{
|
||||
return GetDataSetAll(sql, parameters);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
return Task.Run(() =>
|
||||
{
|
||||
return GetDataSetAll(sql, parameters);
|
||||
},this.CancellationToken.Value);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
@@ -330,7 +330,7 @@ namespace SqlSugar
|
||||
{
|
||||
get
|
||||
{
|
||||
return new List<string>() { "int32", "datetime", "decimal", "double", "byte" };
|
||||
return new List<string>() { "int32", "datetime", "decimal", "double", "byte", "int64", "uint32", "uint64" };
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
@@ -81,7 +81,8 @@ namespace SqlSugar
|
||||
attributeType.GetProperty(nameof(SugarColumn.UpdateSql)),
|
||||
attributeType.GetProperty(nameof(SugarColumn.ExtendedAttribute)),
|
||||
attributeType.GetProperty(nameof(SugarColumn.IsDisabledAlterColumn)),
|
||||
attributeType.GetProperty(nameof(SugarColumn.IsOwnsOne))
|
||||
attributeType.GetProperty(nameof(SugarColumn.IsOwnsOne)),
|
||||
attributeType.GetProperty(nameof(SugarColumn.QuerySql))
|
||||
}
|
||||
, new object[] {
|
||||
sugarTable.IsPrimaryKey,
|
||||
@@ -106,7 +107,8 @@ namespace SqlSugar
|
||||
sugarTable.UpdateSql,
|
||||
sugarTable.ExtendedAttribute,
|
||||
sugarTable.IsDisabledAlterColumn,
|
||||
sugarTable.IsOwnsOne
|
||||
sugarTable.IsOwnsOne,
|
||||
sugarTable.QuerySql
|
||||
});
|
||||
return attributeBuilder;
|
||||
}
|
||||
|
@@ -736,6 +736,7 @@ namespace SqlSugar
|
||||
var addItem = readerValues[info];
|
||||
if (addItem == DBNull.Value)
|
||||
addItem = null;
|
||||
var underType = UtilMethods.GetUnderType(prop.PropertyType);
|
||||
if (prop.PropertyType == UtilConstants.IntType)
|
||||
{
|
||||
addItem = addItem.ObjToInt();
|
||||
@@ -752,6 +753,10 @@ namespace SqlSugar
|
||||
{
|
||||
addItem = addItem.ObjToInt();
|
||||
}
|
||||
else if (addItem!=null&&underType?.FullName == "System.DateOnly")
|
||||
{
|
||||
addItem = Convert.ToDateTime(addItem).ToString("yyyy-MM-dd");
|
||||
}
|
||||
else if (UtilMethods.GetUnderType(prop.PropertyType).IsEnum() && addItem is decimal)
|
||||
{
|
||||
if (prop.PropertyType.IsEnum() == false && addItem == null)
|
||||
|
@@ -950,6 +950,10 @@ namespace SqlSugar
|
||||
if (value is string && type == typeof(Guid)) return new Guid(value as string);
|
||||
if (value is string && type == typeof(Version)) return new Version(value as string);
|
||||
if (!(value is IConvertible)) return value;
|
||||
if(value is DateTime&&type.FullName== "System.DateOnly")
|
||||
{
|
||||
value=UtilMethods.DateTimeToDateOnly(value);
|
||||
}
|
||||
return Convert.ChangeType(value, type);
|
||||
}
|
||||
|
||||
@@ -1710,6 +1714,41 @@ namespace SqlSugar
|
||||
var method = value.GetType().GetMethods().First(it => it.GetParameters().Length == 0 && it.Name == "ToShortDateString");
|
||||
return method.Invoke(value, new object[] { });
|
||||
}
|
||||
internal static object DateTimeToDateOnly(object value)
|
||||
{
|
||||
if (value == null) return null;
|
||||
|
||||
// 获取DateOnly类型
|
||||
Type dateOnlyType = Type.GetType("System.DateOnly, System.Runtime", throwOnError: false);
|
||||
if (dateOnlyType == null)
|
||||
{
|
||||
throw new InvalidOperationException("DateOnly type not found.");
|
||||
}
|
||||
|
||||
// 获取DateOnly的构造函数
|
||||
var constructor = dateOnlyType.GetConstructor(new[] { typeof(int), typeof(int), typeof(int) });
|
||||
if (constructor == null)
|
||||
{
|
||||
throw new InvalidOperationException("DateOnly constructor not found.");
|
||||
}
|
||||
|
||||
// 使用反射调用DateTime的属性
|
||||
var yearProperty = value.GetType().GetProperty("Year");
|
||||
var monthProperty = value.GetType().GetProperty("Month");
|
||||
var dayProperty = value.GetType().GetProperty("Day");
|
||||
|
||||
if (yearProperty == null || monthProperty == null || dayProperty == null)
|
||||
{
|
||||
throw new InvalidOperationException("DateTime properties not found.");
|
||||
}
|
||||
|
||||
int year = (int)yearProperty.GetValue(value);
|
||||
int month = (int)monthProperty.GetValue(value);
|
||||
int day = (int)dayProperty.GetValue(value);
|
||||
|
||||
// 使用反射创建DateOnly实例
|
||||
return constructor.Invoke(new object[] { year, month, day });
|
||||
}
|
||||
|
||||
|
||||
internal static void AddDiscrimator<T>(Type type, ISugarQueryable<T> queryable,string shortName=null)
|
||||
|
Reference in New Issue
Block a user