This commit is contained in:
sunkaixuan 2020-11-10 23:23:38 +08:00
commit e0e7a5249a
8 changed files with 187 additions and 4 deletions

View 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; }
}
}

View File

@ -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" />

View File

@ -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";
}
}

View File

@ -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" />

View 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; }
}
}
}

View File

@ -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);

View File

@ -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;