Merge branch 'SqlSugar5' of https://github.com/donet5/SqlSugar into SqlSugar5

This commit is contained in:
liuchao
2022-10-12 11:34:35 +08:00
8 changed files with 53 additions and 8 deletions

View File

@@ -386,6 +386,7 @@ namespace OrmTest
var allchilds = db.Queryable<Tree>().ToChildList(it => it.ParentId, 0);
var allchilds_2 = db.Queryable<Tree2>().ToChildList(it => it.ParentId, 0);
var allchilds1 = db.Queryable<Tree>().ToChildList(it => it.ParentId, 1);
var allchilds11 = db.Queryable<Tree>().Select<Tree2>().ToChildList(it => it.ParentId, 1);
var allchilds2 = db.Queryable<Tree>().ToChildList(it => it.ParentId, 2);
var allchilds2_2 = db.Queryable<Tree2>().ToChildList(it => it.ParentId, 2);
var parentList = db.Queryable<Tree>().ToParentList(it => it.ParentId, 22);

View File

@@ -54,7 +54,7 @@ using System.Data;
.ExecuteCommand();
Console.WriteLine("用例跑完");
Console.ReadKey();
// Console.ReadKey();
}

View File

@@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("5.1.3.24")]
[assembly: AssemblyFileVersion("5.1.3.24")]
[assembly: AssemblyVersion("5.1.3.25")]
[assembly: AssemblyFileVersion("5.1.3.25")]

View File

@@ -2,7 +2,7 @@
<package >
<metadata>
<id>SqlSugar</id>
<version>5.1.3.24</version>
<version>5.1.3.25</version>
<title>.Net Framework 安装此版本, 5.0.3.3-max 最低要求 .Net Framework 4.6 | 5.0.0.2-5.0.3.2 最低要求 .Net Framework 4.5 | 4.0-4.9.11 最低要求 .Net Framework 4.0+ .NET ORM </title>
<authors>sun kaixuan</authors>
<owners>landa</owners>

View File

@@ -237,9 +237,53 @@ namespace SqlSugar
return "serial";
}
}
#endregion
#endregion
#region Methods
public override bool UpdateColumn(string tableName, DbColumnInfo columnInfo)
{
tableName = this.SqlBuilder.GetTranslationTableName(tableName);
var columnName = this.SqlBuilder.GetTranslationColumnName(columnInfo.DbColumnName);
string type = GetType(tableName, columnInfo);
//this.Context.Ado.ExecuteCommand(sql);
string sql = @"ALTER TABLE {table} ALTER {column} TYPE {type};ALTER TABLE {table} ALTER COLUMN {column} {null}";
var isnull = columnInfo.IsNullable ? " DROP NOT NULL " : " SET NOT NULL ";
sql = sql.Replace("{table}", tableName)
.Replace("{type}", type)
.Replace("{column}", columnName)
.Replace("{null}", isnull);
this.Context.Ado.ExecuteCommand(sql);
return true;
}
protected string GetType(string tableName, DbColumnInfo columnInfo)
{
string columnName = this.SqlBuilder.GetTranslationColumnName(columnInfo.DbColumnName);
tableName = this.SqlBuilder.GetTranslationTableName(tableName);
string dataSize = GetSize(columnInfo);
string dataType = columnInfo.DataType;
//if (!string.IsNullOrEmpty(dataType))
//{
// dataType = dataType;
//}
return dataType + "" + dataSize;
}
public override bool IsAnyColumn(string tableName, string columnName, bool isCache = true)
{
var sql =
$"select count(*) from information_schema.columns WHERE table_schema = 'public' and UPPER(table_name) = '{tableName.ToUpper()}' and UPPER(column_name) = '{columnName.ToUpper()}'";
return this.Context.Ado.GetInt(sql) > 0;
}
public override bool IsAnyTable(string tableName, bool isCache = true)
{
var sql = $"select count(*) from information_schema.tables where table_schema='public' and table_type='BASE TABLE' and UPPER(table_name)='{tableName.ToUpper()}'";
return this.Context.Ado.GetInt(sql)>0;
}
/// <summary>
///by current connection string
/// </summary>

View File

@@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<Version>5.1.3.24</Version>
<Version>5.1.3.25</Version>
<Copyright>sun_kai_xuan</Copyright>
<PackageProjectUrl>https://github.com/sunkaixuan/SqlSugar</PackageProjectUrl>
<PackageLicenseUrl></PackageLicenseUrl>

View File

@@ -2,7 +2,7 @@
<package >
<metadata>
<id>SqlSugarCore</id>
<version>5.1.3.25-preview03</version>
<version>5.1.3.25</version>
<authors>sunkaixuan</authors>
<owners>果糖大数据科技</owners>
<licenseUrl>http://www.apache.org/licenses/LICENSE-2.0.html</licenseUrl>

View File

@@ -2,7 +2,7 @@
<package >
<metadata>
<id>SqlSugarCoreNoDrive</id>
<version>5.1.3.24</version>
<version>5.1.3.25</version>
<authors>sunkaixuan</authors>
<owners>Landa</owners>
<licenseUrl>http://www.apache.org/licenses/LICENSE-2.0.html</licenseUrl>