mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-04-24 18:04:52 +08:00
Update pgsql Storageable WhereColumn bug
This commit is contained in:
parent
eb8bbdafbe
commit
109454c56c
@ -189,7 +189,7 @@ namespace SqlSugar
|
||||
}
|
||||
}
|
||||
|
||||
private static void SetConditList(List<StorageableInfo<T>> itemList, List<EntityColumnInfo> whereColumns, List<IConditionalModel> conditList)
|
||||
private void SetConditList(List<StorageableInfo<T>> itemList, List<EntityColumnInfo> whereColumns, List<IConditionalModel> conditList)
|
||||
{
|
||||
;
|
||||
foreach (var dataItem in itemList)
|
||||
@ -202,11 +202,14 @@ namespace SqlSugar
|
||||
int i = 0;
|
||||
foreach (var item in whereColumns)
|
||||
{
|
||||
var value = item.PropertyInfo.GetValue(dataItem.Item, null);
|
||||
condition.ConditionalList.Add(new KeyValuePair<WhereType, ConditionalModel>(i==0?WhereType.Or :WhereType.And, new ConditionalModel()
|
||||
{
|
||||
FieldName = item.DbColumnName,
|
||||
ConditionalType = ConditionalType.Equal,
|
||||
FieldValue = item.PropertyInfo.GetValue(dataItem.Item, null) + ""
|
||||
FieldValue = value + "",
|
||||
FieldValueConvertFunc=this.Context.CurrentConnectionConfig.DbType==DbType.PostgreSQL?
|
||||
UtilMethods.GetTypeConvert(value):null
|
||||
}));
|
||||
++i;
|
||||
}
|
||||
|
@ -252,6 +252,31 @@ namespace SqlSugar
|
||||
return string.Format(" ({0}) {1} ", sql, shortName);
|
||||
}
|
||||
|
||||
public static Func<string, object> GetTypeConvert(object value)
|
||||
{
|
||||
if (value is int || value is uint || value is int? || value is uint?)
|
||||
{
|
||||
return x => Convert.ToInt32(x);
|
||||
}
|
||||
else if (value is short || value is ushort || value is short? || value is ushort?)
|
||||
{
|
||||
return x => Convert.ToInt16(x);
|
||||
}
|
||||
else if (value is long || value is long? || value is ulong? || value is long?)
|
||||
{
|
||||
return x => Convert.ToInt64(x);
|
||||
}
|
||||
else if (value is DateTime|| value is DateTime?)
|
||||
{
|
||||
return x => Convert.ToDateTime(x);
|
||||
}
|
||||
else if (value is bool||value is bool?)
|
||||
{
|
||||
return x => Convert.ToBoolean(x);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
internal static string GetParenthesesValue(string dbTypeName)
|
||||
{
|
||||
if (Regex.IsMatch(dbTypeName, @"\(.+\)"))
|
||||
|
Loading…
Reference in New Issue
Block a user