mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-10-15 18:55:07 +08:00
Support PgSql Json
This commit is contained in:
@@ -29,8 +29,11 @@ namespace SqlSugar
|
||||
csharpTypeName = "long";
|
||||
if (csharpTypeName.ToLower().IsIn("boolean", "bool"))
|
||||
csharpTypeName = "bool";
|
||||
var mappings = this.MappingTypes.Where(it => it.Value.ToString().Equals(csharpTypeName, StringComparison.CurrentCultureIgnoreCase));
|
||||
return mappings.HasValue() ? mappings.First().Key : "varchar";
|
||||
var mappings = this.MappingTypes.Where(it => it.Value.ToString().Equals(csharpTypeName, StringComparison.CurrentCultureIgnoreCase)).ToList();
|
||||
if (mappings!=null&&mappings.Count>0)
|
||||
return mappings.First().Key;
|
||||
else
|
||||
return "varchar";
|
||||
}
|
||||
public string GetCsharpTypeName(string dbTypeName)
|
||||
{
|
||||
|
@@ -339,6 +339,10 @@ namespace SqlSugar
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (item.IsJson)
|
||||
{
|
||||
paramters.IsJson = true;
|
||||
}
|
||||
this.InsertBuilder.Parameters.Add(paramters);
|
||||
}
|
||||
}
|
||||
@@ -399,6 +403,10 @@ namespace SqlSugar
|
||||
PropertyType = UtilMethods.GetUnderType(column.PropertyInfo),
|
||||
TableId = i
|
||||
};
|
||||
if (column.IsJson)
|
||||
{
|
||||
columnInfo.IsJson = true;
|
||||
}
|
||||
if (columnInfo.PropertyType.IsEnum())
|
||||
{
|
||||
columnInfo.Value = Convert.ToInt64(columnInfo.Value);
|
||||
|
@@ -21,5 +21,6 @@ namespace SqlSugar
|
||||
public object Value { get; set; }
|
||||
public int DecimalDigits { get; set; }
|
||||
public int Scale { get; set; }
|
||||
internal bool IsJson { get; set; }
|
||||
}
|
||||
}
|
||||
|
@@ -233,5 +233,6 @@ namespace SqlSugar
|
||||
|
||||
|
||||
public string TypeName { get; set; }
|
||||
public bool IsJson { get; set; }
|
||||
}
|
||||
}
|
||||
|
@@ -6,6 +6,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Npgsql;
|
||||
using NpgsqlTypes;
|
||||
|
||||
namespace SqlSugar
|
||||
{
|
||||
@@ -94,6 +95,10 @@ namespace SqlSugar
|
||||
sqlParameter.Value = parameter.Value;
|
||||
sqlParameter.DbType = parameter.DbType;
|
||||
sqlParameter.Direction = parameter.Direction;
|
||||
if (parameter.IsJson)
|
||||
{
|
||||
sqlParameter.NpgsqlDbType = NpgsqlDbType.Json;
|
||||
}
|
||||
if (sqlParameter.Direction == 0)
|
||||
{
|
||||
sqlParameter.Direction = ParameterDirection.Input;
|
||||
|
Reference in New Issue
Block a user