mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-07-30 22:10:22 +08:00
Synchronization code
This commit is contained in:
parent
4ccab98181
commit
b8310b8990
@ -153,7 +153,7 @@ namespace SqlSugar
|
||||
var pkInfos = this.Context.EntityMaintenance.GetEntityInfo<T>().Columns.Where(it => it.IsPrimarykey);
|
||||
if (whereExpression==null&&!pkInfos.Any())
|
||||
{
|
||||
Check.Exception(true, "Need primary key or WhereColumn");
|
||||
Check.ExceptionEasy(true, "Need primary key or WhereColumn", "使用Storageable实体需要主键或者使用WhereColumn指定条件列");
|
||||
}
|
||||
if (whereExpression == null && pkInfos.Any())
|
||||
{
|
||||
|
@ -402,6 +402,22 @@ namespace SqlSugar
|
||||
if (item.IsArray)
|
||||
{
|
||||
parameter.IsArray = true;
|
||||
if (item.PropertyType.IsIn(typeof(Guid[]), typeof(Guid?[])))
|
||||
{
|
||||
parameter.DbType = System.Data.DbType.Guid;
|
||||
}
|
||||
else if (item.PropertyType.IsIn(typeof(int[]), typeof(int?[])))
|
||||
{
|
||||
parameter.DbType = System.Data.DbType.Int32;
|
||||
}
|
||||
else if (item.PropertyType.IsIn(typeof(long[]), typeof(long?[])))
|
||||
{
|
||||
parameter.DbType = System.Data.DbType.Int64;
|
||||
}
|
||||
else if (item.PropertyType.IsIn(typeof(short[]), typeof(short?[])))
|
||||
{
|
||||
parameter.DbType = System.Data.DbType.Int16;
|
||||
}
|
||||
}
|
||||
if (item.Value == null && isDic)
|
||||
{
|
||||
|
@ -114,36 +114,7 @@ namespace SqlSugar
|
||||
}
|
||||
if (parameter.IsArray)
|
||||
{
|
||||
// sqlParameter.Value = this.Context.Utilities.SerializeObject(sqlParameter.Value);
|
||||
var type = sqlParameter.Value.GetType();
|
||||
if (ArrayMapping.ContainsKey(type))
|
||||
{
|
||||
sqlParameter.NpgsqlDbType = ArrayMapping[type] | NpgsqlDbType.Array;
|
||||
}
|
||||
else if (type == DBNull.Value.GetType())
|
||||
{
|
||||
if (parameter.DbType.IsIn(System.Data.DbType.Int32))
|
||||
{
|
||||
sqlParameter.NpgsqlDbType = NpgsqlDbType.Integer | NpgsqlDbType.Array;
|
||||
}
|
||||
else if (parameter.DbType.IsIn(System.Data.DbType.Int16))
|
||||
{
|
||||
sqlParameter.NpgsqlDbType = NpgsqlDbType.Smallint | NpgsqlDbType.Array;
|
||||
}
|
||||
else if (parameter.DbType.IsIn(System.Data.DbType.Int64))
|
||||
{
|
||||
sqlParameter.NpgsqlDbType = NpgsqlDbType.Bigint | NpgsqlDbType.Array;
|
||||
}
|
||||
else
|
||||
{
|
||||
sqlParameter.NpgsqlDbType = NpgsqlDbType.Text | NpgsqlDbType.Array;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Check.Exception(true, sqlParameter.Value.GetType().Name + " No Support");
|
||||
}
|
||||
Array(parameter, sqlParameter);
|
||||
}
|
||||
if (sqlParameter.Direction == 0)
|
||||
{
|
||||
@ -173,6 +144,49 @@ namespace SqlSugar
|
||||
return result;
|
||||
}
|
||||
|
||||
private static void Array(SugarParameter parameter, NpgsqlParameter sqlParameter)
|
||||
{
|
||||
// sqlParameter.Value = this.Context.Utilities.SerializeObject(sqlParameter.Value);
|
||||
var type = sqlParameter.Value.GetType();
|
||||
if (ArrayMapping.ContainsKey(type))
|
||||
{
|
||||
sqlParameter.NpgsqlDbType = ArrayMapping[type] | NpgsqlDbType.Array;
|
||||
}
|
||||
else if (type == DBNull.Value.GetType())
|
||||
{
|
||||
DbNullParametrerArray(parameter, sqlParameter);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Check.Exception(true, sqlParameter.Value.GetType().Name + " No Support");
|
||||
}
|
||||
}
|
||||
|
||||
private static void DbNullParametrerArray(SugarParameter parameter, NpgsqlParameter sqlParameter)
|
||||
{
|
||||
if (parameter.DbType.IsIn(System.Data.DbType.Int32))
|
||||
{
|
||||
sqlParameter.NpgsqlDbType = NpgsqlDbType.Integer | NpgsqlDbType.Array;
|
||||
}
|
||||
else if (parameter.DbType.IsIn(System.Data.DbType.Int16))
|
||||
{
|
||||
sqlParameter.NpgsqlDbType = NpgsqlDbType.Smallint | NpgsqlDbType.Array;
|
||||
}
|
||||
else if (parameter.DbType.IsIn(System.Data.DbType.Int64))
|
||||
{
|
||||
sqlParameter.NpgsqlDbType = NpgsqlDbType.Bigint | NpgsqlDbType.Array;
|
||||
}
|
||||
else if (parameter.DbType.IsIn(System.Data.DbType.Guid))
|
||||
{
|
||||
sqlParameter.NpgsqlDbType = NpgsqlDbType.Uuid | NpgsqlDbType.Array;
|
||||
}
|
||||
else
|
||||
{
|
||||
sqlParameter.NpgsqlDbType = NpgsqlDbType.Text | NpgsqlDbType.Array;
|
||||
}
|
||||
}
|
||||
|
||||
private static void UNumber(SugarParameter parameter)
|
||||
{
|
||||
if (parameter.DbType == System.Data.DbType.UInt16)
|
||||
|
Loading…
Reference in New Issue
Block a user