Browse Source

Where(ConditionalModels) byte array bug

pull/18/MERGE
sunkaixuan 3 years ago
parent
commit
b196b53d8b
  1. 2
      Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs
  2. 9
      Src/Asp.Net/SqlSugar/Utilities/UtilConvert.cs
  3. 14
      Src/Asp.Net/SqlSugar/Utilities/UtilMethods.cs

2
Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs

@ -443,7 +443,7 @@ namespace SqlSugar
{ {
ConditionalType = ConditionalType.Equal, ConditionalType = ConditionalType.Equal,
FieldName = this.QueryBuilder.Builder.GetTranslationColumnName(column.DbColumnName), FieldName = this.QueryBuilder.Builder.GetTranslationColumnName(column.DbColumnName),
FieldValue = value.ObjToString(), FieldValue = value.ObjToStringNew(),
CSharpTypeName = column.PropertyInfo.PropertyType.Name CSharpTypeName = column.PropertyInfo.PropertyType.Name
}); });
if (this.Context.CurrentConnectionConfig.DbType == DbType.PostgreSQL) if (this.Context.CurrentConnectionConfig.DbType == DbType.PostgreSQL)

9
Src/Asp.Net/SqlSugar/Utilities/UtilConvert.cs

@ -71,6 +71,15 @@ namespace SqlSugar
if (thisValue != null) return thisValue.ToString().Trim(); if (thisValue != null) return thisValue.ToString().Trim();
return ""; return "";
} }
public static string ObjToStringNew(this object thisValue)
{
if (thisValue != null && thisValue is byte[])
{
return string.Join("|",thisValue as byte[]);
}
if (thisValue != null) return thisValue.ToString().Trim();
return "";
}
public static string ObjToString(this object thisValue, string errorValue) public static string ObjToString(this object thisValue, string errorValue)
{ {

14
Src/Asp.Net/SqlSugar/Utilities/UtilMethods.cs

@ -557,7 +557,7 @@ namespace SqlSugar
{ {
return Convert.ToInt32(item.FieldValue); return Convert.ToInt32(item.FieldValue);
} }
else if (item.CSharpTypeName .EqualCase("long")) else if (item.CSharpTypeName.EqualCase("long"))
{ {
return Convert.ToInt64(item.FieldValue); return Convert.ToInt64(item.FieldValue);
} }
@ -569,11 +569,11 @@ namespace SqlSugar
{ {
return Convert.ToByte(item.FieldValue); return Convert.ToByte(item.FieldValue);
} }
else if (item.CSharpTypeName.EqualCase( "uint")) else if (item.CSharpTypeName.EqualCase("uint"))
{ {
return Convert.ToUInt32(item.FieldValue); return Convert.ToUInt32(item.FieldValue);
} }
else if (item.CSharpTypeName.EqualCase( "ulong")) else if (item.CSharpTypeName.EqualCase("ulong"))
{ {
return Convert.ToUInt64(item.FieldValue); return Convert.ToUInt64(item.FieldValue);
} }
@ -581,11 +581,11 @@ namespace SqlSugar
{ {
return Convert.ToUInt16(item.FieldValue); return Convert.ToUInt16(item.FieldValue);
} }
else if (item.CSharpTypeName.EqualCase( "uint32")) else if (item.CSharpTypeName.EqualCase("uint32"))
{ {
return Convert.ToUInt32(item.FieldValue); return Convert.ToUInt32(item.FieldValue);
} }
else if (item.CSharpTypeName.EqualCase( "uint64")) else if (item.CSharpTypeName.EqualCase("uint64"))
{ {
return Convert.ToUInt64(item.FieldValue); return Convert.ToUInt64(item.FieldValue);
} }
@ -593,6 +593,10 @@ namespace SqlSugar
{ {
return Convert.ToUInt16(item.FieldValue); return Convert.ToUInt16(item.FieldValue);
} }
else if (item.CSharpTypeName.EqualCase("byte[]")&&item.FieldValue!=null&&item.FieldValue.Contains("|"))
{
return item.FieldValue.Split('|').Select(it=>Convert.ToByte(it)).ToArray();
}
else else
{ {
return item.FieldValue; return item.FieldValue;

Loading…
Cancel
Save