mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-01 19:15:10 +08:00
Merge branch 'SqlSugar5' of https://github.com/sunkaixuan/SqlSugar
This commit is contained in:
commit
e0e7a5249a
45
Src/Asp.Net/DmTest/BugTest/BugTest1.cs
Normal file
45
Src/Asp.Net/DmTest/BugTest/BugTest1.cs
Normal file
@ -0,0 +1,45 @@
|
||||
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 BugTest1
|
||||
{
|
||||
public static void Init()
|
||||
{
|
||||
SqlSugarClient Db = new SqlSugarClient(new ConnectionConfig()
|
||||
{
|
||||
ConnectionString = Config.ConnectionString,
|
||||
DbType = DbType.Dm,
|
||||
IsAutoCloseConnection = true,
|
||||
|
||||
InitKeyType = InitKeyType.Attribute,
|
||||
});
|
||||
//调式代码 用来打印SQL
|
||||
Db.Aop.OnLogExecuting = (sql, pars) =>
|
||||
{
|
||||
Console.WriteLine(sql);
|
||||
};
|
||||
|
||||
Db.CodeFirst.InitTables(typeof(testmmxxxmm121));
|
||||
var id = Guid.NewGuid();
|
||||
Db.Insertable(new testmmxxxmm121() { x = id }).ExecuteCommand();
|
||||
var x= Db.Queryable<testmmxxxmm121>().Where(it => it.x.ToString().ToUpper() == id.ToString().ToUpper()).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
public class testmmxxxmm121
|
||||
{
|
||||
[SugarColumn(IsPrimaryKey =true,IsIdentity =true)]
|
||||
public int id { get; set; }
|
||||
[SugarColumn(ColumnDataType ="varchar(36)")]
|
||||
public Guid x { get; set; }
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -44,6 +44,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Config.cs" />
|
||||
<Compile Include="BugTest\BugTest1.cs" />
|
||||
<Compile Include="Demo\Demo0_SqlSugarClient.cs" />
|
||||
<Compile Include="Demo\Demo1_Queryable.cs" />
|
||||
<Compile Include="Demo\Demo2_Updateable.cs" />
|
||||
|
@ -16,16 +16,16 @@ namespace OrmTest
|
||||
/// Account have permission to create database
|
||||
/// 用有建库权限的数据库账号
|
||||
/// </summary>
|
||||
public static string ConnectionString = "PORT=5433;DATABASE=SqlSugar4xTest;HOST=localhost;PASSWORD=haosql;USER ID=postgres";
|
||||
public static string ConnectionString = "PORT=5432;DATABASE=SqlSugar4xTest;HOST=localhost;PASSWORD=haosql;USER ID=postgres";
|
||||
/// <summary>
|
||||
/// Account have permission to create database
|
||||
/// 用有建库权限的数据库账号
|
||||
/// </summary>
|
||||
public static string ConnectionString2 = "PORT=5433;DATABASE=SqlSugar4xTest2;HOST=localhost;PASSWORD=haosql;USER ID=postgres";
|
||||
public static string ConnectionString2 = "PORT=5432;DATABASE=SqlSugar4xTest2;HOST=localhost;PASSWORD=haosql;USER ID=postgres";
|
||||
/// <summary>
|
||||
/// Account have permission to create database
|
||||
/// 用有建库权限的数据库账号
|
||||
/// </summary>
|
||||
public static string ConnectionString3 = "PORT=5433;DATABASE=SqlSugar4xTest3;HOST=localhost;PASSWORD=haosql;USER ID=postgres";
|
||||
public static string ConnectionString3 = "PORT=5432;DATABASE=SqlSugar4xTest3;HOST=localhost;PASSWORD=haosql;USER ID=postgres";
|
||||
}
|
||||
}
|
||||
|
@ -79,6 +79,7 @@
|
||||
<Compile Include="Models\ViewOrder.cs" />
|
||||
<Compile Include="UnitTest\UQueue.cs" />
|
||||
<Compile Include="_OldTest\BugTest\Bug2.cs" />
|
||||
<Compile Include="_OldTest\BugTest\Bug5.cs" />
|
||||
<Compile Include="_OldTest\BugTest\Bug4.cs" />
|
||||
<Compile Include="_OldTest\BugTest\BugModels\AccountsModel.cs" />
|
||||
<Compile Include="_OldTest\BugTest\BugModels\ClientsModel.cs" />
|
||||
@ -93,7 +94,7 @@
|
||||
<Compile Include="_OldTest\BugTest\BugModels\TStock.cs" />
|
||||
<Compile Include="_OldTest\BugTest\BugModels\TTempStock.cs" />
|
||||
<Compile Include="_OldTest\BugTest\BugModels\VMaterialInfo.cs" />
|
||||
<Compile Include="_OldTest\BugTest\Bug3t.cs" />
|
||||
<Compile Include="_OldTest\BugTest\Bug3.cs" />
|
||||
<Compile Include="_OldTest\Demos\H_Queue.cs" />
|
||||
<Compile Include="_OldTest\Demos\I_InsertOrUpdate.cs" />
|
||||
<Compile Include="_OldTest\Demos\J_Debugger.cs" />
|
||||
|
128
Src/Asp.Net/SqlServerTest/_OldTest/BugTest/Bug5.cs
Normal file
128
Src/Asp.Net/SqlServerTest/_OldTest/BugTest/Bug5.cs
Normal file
@ -0,0 +1,128 @@
|
||||
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 BugTest5
|
||||
{
|
||||
public static void Init()
|
||||
{
|
||||
SqlSugarClient Db = new SqlSugarClient(new ConnectionConfig()
|
||||
{
|
||||
ConnectionString = Config.ConnectionString,
|
||||
DbType = DbType.SqlServer,
|
||||
IsAutoCloseConnection = true,
|
||||
//MoreSettings = new ConnMoreSettings()
|
||||
//{
|
||||
// PgSqlIsAutoToLower = true //我们这里需要设置为false
|
||||
//},
|
||||
InitKeyType = InitKeyType.Attribute,
|
||||
});
|
||||
//调式代码 用来打印SQL
|
||||
Db.Aop.OnLogExecuting = (sql, pars) =>
|
||||
{
|
||||
Console.WriteLine(sql);
|
||||
};
|
||||
|
||||
Db.CodeFirst.InitTables(typeof(Base_MenuList));
|
||||
Db.CodeFirst.InitTables(typeof(aaaa));
|
||||
Db.CodeFirst.InitTables(typeof(bbbbb));
|
||||
|
||||
}
|
||||
[SugarTable("xxxx.Base_MenuList")]
|
||||
|
||||
public class Base_MenuList
|
||||
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
|
||||
/// 菜单主键Id
|
||||
|
||||
/// </summary>
|
||||
|
||||
[SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnDescription = "菜单主键Id")]
|
||||
|
||||
public int MenuID { get; set; }
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
|
||||
/// 名称
|
||||
|
||||
/// </summary>
|
||||
|
||||
[SugarColumn(IsNullable = false, Length = 50, ColumnDescription = "名称")]
|
||||
|
||||
public string MenuName { get; set; }
|
||||
|
||||
}
|
||||
|
||||
[SugarTable("xxxx1x")]
|
||||
|
||||
public class aaaa
|
||||
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
|
||||
/// 菜单主键Id
|
||||
|
||||
/// </summary>
|
||||
|
||||
[SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnDescription = "菜单主键Id")]
|
||||
|
||||
public int MenuID { get; set; }
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
|
||||
/// 名称
|
||||
|
||||
/// </summary>
|
||||
|
||||
[SugarColumn(IsNullable = false, Length = 50, ColumnDescription = "名称")]
|
||||
|
||||
public string MenuName { get; set; }
|
||||
|
||||
}
|
||||
[SugarTable("bbbbb")]
|
||||
|
||||
public class bbbbb
|
||||
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
|
||||
/// 菜单主键Id
|
||||
|
||||
/// </summary>
|
||||
|
||||
[SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnDescription = "菜单主键Id")]
|
||||
|
||||
public int MenuID { get; set; }
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
|
||||
/// 名称
|
||||
|
||||
/// </summary>
|
||||
|
||||
[SugarColumn(IsNullable = false, Length = 50, ColumnDescription = "名称")]
|
||||
|
||||
public string MenuName { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -109,6 +109,9 @@ namespace SqlSugar
|
||||
}
|
||||
}
|
||||
var tableName = GetTableName(entityInfo);
|
||||
this.Context.MappingTables.Add(entityInfo.EntityName,tableName);
|
||||
entityInfo.DbTableName = tableName;
|
||||
entityInfo.Columns.ForEach(it => { it.DbTableName = tableName; });
|
||||
var isAny = this.Context.DbMaintenance.IsAnyTable(tableName);
|
||||
if (isAny)
|
||||
ExistLogic(entityInfo);
|
||||
|
@ -117,6 +117,11 @@ namespace SqlSugar
|
||||
sqlParameter.Size = parameter.Size;
|
||||
sqlParameter.Value = parameter.Value;
|
||||
sqlParameter.DbType = parameter.DbType;
|
||||
if (sqlParameter.DbType == System.Data.DbType.Guid)
|
||||
{
|
||||
sqlParameter.DbType = System.Data.DbType.String;
|
||||
sqlParameter.Value = sqlParameter.Value.ToString();
|
||||
}
|
||||
if (parameter.Direction == 0)
|
||||
{
|
||||
parameter.Direction = ParameterDirection.Input;
|
||||
|
Loading…
Reference in New Issue
Block a user