mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-25 01:14:33 +08:00
Update Core
This commit is contained in:
parent
186c67acf2
commit
659f784889
227
Src/Asp.NetCore2/SqlSeverTest/PgSqlTest/Bugs/BugTest.cs
Normal file
227
Src/Asp.NetCore2/SqlSeverTest/PgSqlTest/Bugs/BugTest.cs
Normal file
@ -0,0 +1,227 @@
|
|||||||
|
//using SqlSugar;
|
||||||
|
//using System;
|
||||||
|
//using System.Collections.Generic;
|
||||||
|
//using System.ComponentModel.DataAnnotations;
|
||||||
|
//using System.Linq;
|
||||||
|
//using System.Text;
|
||||||
|
//using System.Threading.Tasks;
|
||||||
|
|
||||||
|
//namespace OrmTest.Test
|
||||||
|
//{
|
||||||
|
// public class BugTest
|
||||||
|
// {
|
||||||
|
// public static void Init()
|
||||||
|
// {
|
||||||
|
// SqlSugarClient Db = new SqlSugarClient(new ConnectionConfig()
|
||||||
|
// {
|
||||||
|
// ConnectionString = @"PORT=5433;DATABASE=x;HOST=localhost;PASSWORD=haosql;USER ID=postgres",
|
||||||
|
// DbType = DbType.PostgreSQL,
|
||||||
|
// IsAutoCloseConnection = true,
|
||||||
|
// //MoreSettings = new ConnMoreSettings()
|
||||||
|
// //{
|
||||||
|
// // PgSqlIsAutoToLower = true //我们这里需要设置为false
|
||||||
|
// //},
|
||||||
|
// InitKeyType = InitKeyType.Attribute,
|
||||||
|
// });
|
||||||
|
// //调式代码 用来打印SQL
|
||||||
|
// Db.Aop.OnLogExecuting = (sql, pars) =>
|
||||||
|
// {
|
||||||
|
// // Debug.WriteLine(sql);
|
||||||
|
// };
|
||||||
|
|
||||||
|
// var 查询成功 = Db.Queryable<Sys_Menu>()
|
||||||
|
// .Where(x => x.Enable == true) //不加 ture ,也会出错
|
||||||
|
// .ToList();
|
||||||
|
|
||||||
|
|
||||||
|
// var Dbfirst情况使用Mapper_Menu_Id为大写自动转成小写 = Db.Queryable<Sys_Menu>()
|
||||||
|
// .Where(x => x.Enable == true)
|
||||||
|
// .Mapper(x => x.orderList, x => x.Menu_Id) //初始化数据库失败42703: 字段 "menu_id" 不存在
|
||||||
|
// .ToList();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// public class Sys_RoleAuth
|
||||||
|
// {
|
||||||
|
// /// <summary>
|
||||||
|
// ///
|
||||||
|
// /// </summary>
|
||||||
|
// [Key]
|
||||||
|
// [Display(Name = "")]
|
||||||
|
// [SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
|
||||||
|
// public int Auth_Id { get; set; }
|
||||||
|
|
||||||
|
// /// <summary>
|
||||||
|
// ///
|
||||||
|
// /// </summary>
|
||||||
|
// [Display(Name = "")]
|
||||||
|
// public int Role_Id { get; set; }
|
||||||
|
|
||||||
|
// /// <summary>
|
||||||
|
// ///
|
||||||
|
// /// </summary>
|
||||||
|
// [Display(Name = "")]
|
||||||
|
// public int User_Id { get; set; }
|
||||||
|
|
||||||
|
// /// <summary>
|
||||||
|
// ///
|
||||||
|
// /// </summary>
|
||||||
|
// [Display(Name = "")]
|
||||||
|
// [SugarColumn(IsNullable = false)]
|
||||||
|
// public int Menu_Id { get; set; }
|
||||||
|
|
||||||
|
// /// <summary>
|
||||||
|
// ///用户权限
|
||||||
|
// /// </summary>
|
||||||
|
// [Display(Name = "用户权限")]
|
||||||
|
// [SugarColumn(IsNullable = false, IsJson = true, ColumnDataType = "json")]
|
||||||
|
// public List<Sys_Actions> AuthValue { get; set; } = new List<Sys_Actions>();
|
||||||
|
|
||||||
|
// /// <summary>
|
||||||
|
// ///
|
||||||
|
// /// </summary>
|
||||||
|
// [Display(Name = "")]
|
||||||
|
// [MaxLength(100)]
|
||||||
|
// public string Creator { get; set; }
|
||||||
|
|
||||||
|
// /// <summary>
|
||||||
|
// ///
|
||||||
|
// /// </summary>
|
||||||
|
// [Display(Name = "")]
|
||||||
|
// public DateTime CreateDate { get; set; }
|
||||||
|
|
||||||
|
// /// <summary>
|
||||||
|
// ///
|
||||||
|
// /// </summary>
|
||||||
|
// [Display(Name = "")]
|
||||||
|
// [MaxLength(100)]
|
||||||
|
// public string Modifier { get; set; }
|
||||||
|
|
||||||
|
// /// <summary>
|
||||||
|
// ///
|
||||||
|
// /// </summary>
|
||||||
|
// [Display(Name = "")]
|
||||||
|
// public DateTime ModifyDate { get; set; }
|
||||||
|
// }
|
||||||
|
// public class Sys_Actions
|
||||||
|
// {
|
||||||
|
// public int Action_Id { get; set; }
|
||||||
|
// public int Menu_Id { get; set; }
|
||||||
|
// public string Text { get; set; }
|
||||||
|
// public string Value { get; set; }
|
||||||
|
// }
|
||||||
|
// public class Sys_Menu
|
||||||
|
// {
|
||||||
|
// /// <summary>
|
||||||
|
// ///ID
|
||||||
|
// /// </summary>
|
||||||
|
// [Key]
|
||||||
|
// [Display(Name = "ID")]
|
||||||
|
// [SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
|
||||||
|
// public int Menu_Id { get; set; }
|
||||||
|
|
||||||
|
// /// <summary>
|
||||||
|
// ///父级ID
|
||||||
|
// /// </summary>
|
||||||
|
// [Display(Name = "父级ID")]
|
||||||
|
// [SugarColumn(IsNullable = false)]
|
||||||
|
// public int ParentId { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
// /// <summary>
|
||||||
|
// ///菜单名称
|
||||||
|
// /// </summary>
|
||||||
|
// [Display(Name = "菜单名称")]
|
||||||
|
// [MaxLength(50)]
|
||||||
|
// [SugarColumn(IsNullable = false)]
|
||||||
|
// public string MenuName { get; set; }
|
||||||
|
|
||||||
|
// /// <summary>
|
||||||
|
// ///
|
||||||
|
// /// </summary>
|
||||||
|
// [Display(Name = "TableName")]
|
||||||
|
// [MaxLength(200)]
|
||||||
|
// public string TableName { get; set; }
|
||||||
|
|
||||||
|
// /// <summary>
|
||||||
|
// ///
|
||||||
|
// /// </summary>
|
||||||
|
// [Display(Name = "Url")]
|
||||||
|
// [MaxLength(10000)]
|
||||||
|
// public string Url { get; set; }
|
||||||
|
|
||||||
|
// /// <summary>
|
||||||
|
// ///权限
|
||||||
|
// /// </summary>
|
||||||
|
// [Display(Name = "权限")]
|
||||||
|
// [MaxLength(-1)]
|
||||||
|
// [SugarColumn(IsNullable = false, IsJson = true, ColumnDataType = "json")]
|
||||||
|
// public List<Sys_Actions> Auth { get; set; } = new List<Sys_Actions>();
|
||||||
|
|
||||||
|
// /// <summary>
|
||||||
|
// ///
|
||||||
|
// /// </summary>
|
||||||
|
// [Display(Name = "Description")]
|
||||||
|
// [MaxLength(200)]
|
||||||
|
// public string Description { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
// /// <summary>
|
||||||
|
// ///图标
|
||||||
|
// /// </summary>
|
||||||
|
// [Display(Name = "图标")]
|
||||||
|
// [MaxLength(50)]
|
||||||
|
// public string Icon { get; set; }
|
||||||
|
|
||||||
|
// /// <summary>
|
||||||
|
// ///排序号
|
||||||
|
// /// </summary>
|
||||||
|
// [Display(Name = "排序号")]
|
||||||
|
// public int OrderNo { get; set; }
|
||||||
|
|
||||||
|
// /// <summary>
|
||||||
|
// ///创建人
|
||||||
|
// /// </summary>
|
||||||
|
// [Display(Name = "创建人")]
|
||||||
|
// [MaxLength(50)]
|
||||||
|
// public string Creator { get; set; }
|
||||||
|
|
||||||
|
// /// <summary>
|
||||||
|
// ///创建时间
|
||||||
|
// /// </summary>
|
||||||
|
// [Display(Name = "创建时间")]
|
||||||
|
// public DateTime? CreateDate { get; set; } = DateTime.Now;
|
||||||
|
|
||||||
|
// /// <summary>
|
||||||
|
// ///
|
||||||
|
// /// </summary>
|
||||||
|
// [Display(Name = "Modifier")]
|
||||||
|
// [MaxLength(50)]
|
||||||
|
// public string Modifier { get; set; }
|
||||||
|
|
||||||
|
// /// <summary>
|
||||||
|
// ///
|
||||||
|
// /// </summary>
|
||||||
|
// [Display(Name = "ModifyDate")]
|
||||||
|
// public DateTime? ModifyDate { get; set; }
|
||||||
|
|
||||||
|
// /// <summary>
|
||||||
|
// ///是否启用
|
||||||
|
// /// </summary>
|
||||||
|
// [Display(Name = "是否启用")]
|
||||||
|
// public bool Enable { get; set; }
|
||||||
|
|
||||||
|
// [SugarColumn(IsIgnore = true)]
|
||||||
|
// public List<Order> orderList { get; set; }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// public class Order
|
||||||
|
// {
|
||||||
|
// [Key]
|
||||||
|
// [Display(Name = "ID")]
|
||||||
|
// [SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
|
||||||
|
// public int Id { get; set; }
|
||||||
|
|
||||||
|
// public int Menu_Id { get; set; }
|
||||||
|
// }
|
||||||
|
|
||||||
|
//}
|
53
Src/Asp.NetCore2/SqlSeverTest/PgSqlTest/Bugs/BugTest2.cs
Normal file
53
Src/Asp.NetCore2/SqlSeverTest/PgSqlTest/Bugs/BugTest2.cs
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace OrmTest.Test
|
||||||
|
{
|
||||||
|
public class BugTest
|
||||||
|
{
|
||||||
|
public static void Init()
|
||||||
|
{
|
||||||
|
SqlSugarClient Db = new SqlSugarClient(new ConnectionConfig()
|
||||||
|
{
|
||||||
|
ConnectionString = @"PORT=5433;DATABASE=x;HOST=localhost;PASSWORD=haosql;USER ID=postgres",
|
||||||
|
DbType = DbType.PostgreSQL,
|
||||||
|
IsAutoCloseConnection = true,
|
||||||
|
//MoreSettings = new ConnMoreSettings()
|
||||||
|
//{
|
||||||
|
// PgSqlIsAutoToLower = true //我们这里需要设置为false
|
||||||
|
//},
|
||||||
|
InitKeyType = InitKeyType.Attribute,
|
||||||
|
});
|
||||||
|
//调式代码 用来打印SQL
|
||||||
|
Db.Aop.OnLogExecuting = (sql, pars) =>
|
||||||
|
{
|
||||||
|
// Debug.WriteLine(sql);
|
||||||
|
};
|
||||||
|
|
||||||
|
Db.CodeFirst.InitTables(typeof(My12311x1));
|
||||||
|
|
||||||
|
var id = Db.Insertable(new My12311x1 { Menu_Id = new int[] { 1, 2 } }).ExecuteReturnIdentity();
|
||||||
|
var list = Db.Queryable<My12311x1>().InSingle(id);
|
||||||
|
list.Menu_Id = new int[] { 3 };
|
||||||
|
Db.Updateable(list).ExecuteCommand();
|
||||||
|
list = Db.Queryable<My12311x1>().InSingle(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class My12311x1
|
||||||
|
{
|
||||||
|
[Key]
|
||||||
|
[Display(Name = "ID")]
|
||||||
|
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
[SugarColumn(ColumnDataType = "int []", IsArray = true)]
|
||||||
|
public int[] Menu_Id { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
46
Src/Asp.NetCore2/SqlSeverTest/PgSqlTest/Bugs/BugTest3.cs
Normal file
46
Src/Asp.NetCore2/SqlSeverTest/PgSqlTest/Bugs/BugTest3.cs
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
//using SqlSugar;
|
||||||
|
//using System;
|
||||||
|
//using System.Collections.Generic;
|
||||||
|
//using System.ComponentModel.DataAnnotations;
|
||||||
|
//using System.Linq;
|
||||||
|
//using System.Text;
|
||||||
|
//using System.Threading.Tasks;
|
||||||
|
|
||||||
|
//namespace OrmTest.Test
|
||||||
|
//{
|
||||||
|
// public class BugTest
|
||||||
|
// {
|
||||||
|
// public static void Init()
|
||||||
|
// {
|
||||||
|
// SqlSugarClient Db = new SqlSugarClient(new ConnectionConfig()
|
||||||
|
// {
|
||||||
|
// ConnectionString = @"PORT=5433;DATABASE=x;HOST=localhost;PASSWORD=haosql;USER ID=postgres",
|
||||||
|
// DbType = DbType.PostgreSQL,
|
||||||
|
// IsAutoCloseConnection = true,
|
||||||
|
|
||||||
|
// InitKeyType = InitKeyType.Attribute,
|
||||||
|
// });
|
||||||
|
// //调式代码 用来打印SQL
|
||||||
|
// Db.Aop.OnLogExecuting = (sql, pars) =>
|
||||||
|
// {
|
||||||
|
// Console.WriteLine(sql);
|
||||||
|
// };
|
||||||
|
|
||||||
|
// Db.CodeFirst.InitTables(typeof(testmmmm121));
|
||||||
|
|
||||||
|
// var id = Db.Insertable(new testmmmm121 { name = "a", isok = true }).ExecuteReturnIdentity();
|
||||||
|
// var list = Db.Queryable<testmmmm121>().InSingle(id);
|
||||||
|
// var x = Db.Queryable<testmmmm121>().Where(it => !it.isok).ToList();
|
||||||
|
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// public class testmmmm121
|
||||||
|
// {
|
||||||
|
// [SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
|
||||||
|
// public int id { get; set; }
|
||||||
|
// public string name { get; set; }
|
||||||
|
// public bool isok { get; set; }
|
||||||
|
// }
|
||||||
|
|
||||||
|
//}
|
@ -1341,7 +1341,7 @@ namespace SqlSugar
|
|||||||
if (item.Value != null)
|
if (item.Value != null)
|
||||||
{
|
{
|
||||||
var type = item.Value.GetType();
|
var type = item.Value.GetType();
|
||||||
if ((type != UtilConstants.ByteArrayType && type.IsArray) || type.FullName.IsCollectionsList())
|
if ((type != UtilConstants.ByteArrayType && type.IsArray && item.IsArray == false) || type.FullName.IsCollectionsList())
|
||||||
{
|
{
|
||||||
var newValues = new List<string>();
|
var newValues = new List<string>();
|
||||||
foreach (var inValute in item.Value as IEnumerable)
|
foreach (var inValute in item.Value as IEnumerable)
|
||||||
|
Loading…
Reference in New Issue
Block a user