mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-11-08 02:14:53 +08:00
Update .net core project
This commit is contained in:
@@ -106,6 +106,16 @@ namespace SqlSugar
|
|||||||
var result=columns.Any(it => it.IsPrimarykey == true && it.DbColumnName.Equals(columnName, StringComparison.CurrentCultureIgnoreCase));
|
var result=columns.Any(it => it.IsPrimarykey == true && it.DbColumnName.Equals(columnName, StringComparison.CurrentCultureIgnoreCase));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
public virtual bool IsPrimaryKey(string tableName, string columnName,bool isCache=true)
|
||||||
|
{
|
||||||
|
columnName = this.SqlBuilder.GetNoTranslationColumnName(columnName);
|
||||||
|
var isAny = IsAnyTable(tableName, isCache);
|
||||||
|
Check.Exception(!isAny, string.Format("Table {0} does not exist", tableName));
|
||||||
|
var columns = GetColumnInfosByTableName(tableName,isCache);
|
||||||
|
if (columns.IsNullOrEmpty()) return false;
|
||||||
|
var result = columns.Any(it => it.IsPrimarykey == true && it.DbColumnName.Equals(columnName, StringComparison.CurrentCultureIgnoreCase));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
public virtual bool IsIdentity(string tableName, string columnName)
|
public virtual bool IsIdentity(string tableName, string columnName)
|
||||||
{
|
{
|
||||||
columnName = this.SqlBuilder.GetNoTranslationColumnName(columnName);
|
columnName = this.SqlBuilder.GetNoTranslationColumnName(columnName);
|
||||||
|
|||||||
@@ -1341,7 +1341,11 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region
|
#region Other
|
||||||
|
public SqlSugarClient CopyNew()
|
||||||
|
{
|
||||||
|
return new SqlSugarClient(UtilMethods.CopyConfig(this.Ado.Context.CurrentConnectionConfig));
|
||||||
|
}
|
||||||
public void ThenMapper<T>(IEnumerable<T> list, Action<T> action)
|
public void ThenMapper<T>(IEnumerable<T> list, Action<T> action)
|
||||||
{
|
{
|
||||||
MapperContext<T> result = new MapperContext<T>();
|
MapperContext<T> result = new MapperContext<T>();
|
||||||
|
|||||||
@@ -706,6 +706,10 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
return ScopedContext.UpdateNav(datas);
|
return ScopedContext.UpdateNav(datas);
|
||||||
}
|
}
|
||||||
|
public SqlSugarClient CopyNew()
|
||||||
|
{
|
||||||
|
return new SqlSugarClient(UtilMethods.CopyConfig(this.Ado.Context.CurrentConnectionConfig));
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -55,6 +55,14 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
var shortName = item.ThisEntityInfo.DbTableName + i;
|
var shortName = item.ThisEntityInfo.DbTableName + i;
|
||||||
var pkColumn = item.ThisEntityInfo.Columns.FirstOrDefault(it => it.IsPrimarykey);
|
var pkColumn = item.ThisEntityInfo.Columns.FirstOrDefault(it => it.IsPrimarykey);
|
||||||
|
if (item.Nav.Name2.HasValue())
|
||||||
|
{
|
||||||
|
var nav2NameColumn = item.ThisEntityInfo.Columns.FirstOrDefault(it => it.PropertyName==item.Nav.Name2);
|
||||||
|
if (nav2NameColumn != null)
|
||||||
|
{
|
||||||
|
pkColumn = nav2NameColumn;
|
||||||
|
}
|
||||||
|
}
|
||||||
var navColum = item.ParentEntityInfo.Columns.FirstOrDefault(it => it.PropertyName == item.Nav.Name);
|
var navColum = item.ParentEntityInfo.Columns.FirstOrDefault(it => it.PropertyName == item.Nav.Name);
|
||||||
Check.ExceptionEasy(pkColumn == null, $"{item.ThisEntityInfo.EntityName} need PrimayKey", $"使用导航属性{item.ThisEntityInfo.EntityName} 缺少主键");
|
Check.ExceptionEasy(pkColumn == null, $"{item.ThisEntityInfo.EntityName} need PrimayKey", $"使用导航属性{item.ThisEntityInfo.EntityName} 缺少主键");
|
||||||
var on = $" {ToShortName(shortName)}.{queryable.SqlBuilder.GetTranslationColumnName(pkColumn.DbColumnName)}={ToShortName(formInfo.ThisEntityInfo.DbTableName + (i - 1))}.{queryable.SqlBuilder.GetTranslationColumnName(navColum.DbColumnName)}";
|
var on = $" {ToShortName(shortName)}.{queryable.SqlBuilder.GetTranslationColumnName(pkColumn.DbColumnName)}={ToShortName(formInfo.ThisEntityInfo.DbTableName + (i - 1))}.{queryable.SqlBuilder.GetTranslationColumnName(navColum.DbColumnName)}";
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ namespace SqlSugar
|
|||||||
bool IsAnyTable(string tableName, bool isCache = true);
|
bool IsAnyTable(string tableName, bool isCache = true);
|
||||||
bool IsAnyColumn(string tableName, string column, bool isCache = true);
|
bool IsAnyColumn(string tableName, string column, bool isCache = true);
|
||||||
bool IsPrimaryKey(string tableName, string column);
|
bool IsPrimaryKey(string tableName, string column);
|
||||||
|
bool IsPrimaryKey(string tableName, string column,bool isCache=true);
|
||||||
bool IsIdentity(string tableName, string column);
|
bool IsIdentity(string tableName, string column);
|
||||||
bool IsAnyConstraint(string ConstraintName);
|
bool IsAnyConstraint(string ConstraintName);
|
||||||
bool IsAnySystemTablePermissions();
|
bool IsAnySystemTablePermissions();
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ namespace SqlSugar
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Other methods
|
#region Other methods
|
||||||
|
SqlSugarClient CopyNew();
|
||||||
T CreateContext<T>(bool isTran=true) where T : SugarUnitOfWork, new();
|
T CreateContext<T>(bool isTran=true) where T : SugarUnitOfWork, new();
|
||||||
SugarUnitOfWork CreateContext(bool isTran = true);
|
SugarUnitOfWork CreateContext(bool isTran = true);
|
||||||
SplitTableContext SplitHelper<T>() where T : class, new();
|
SplitTableContext SplitHelper<T>() where T : class, new();
|
||||||
|
|||||||
@@ -308,7 +308,9 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
var oldDatabaseName = this.Context.Ado.Connection.Database;
|
var oldDatabaseName = this.Context.Ado.Connection.Database;
|
||||||
var connection = this.Context.CurrentConnectionConfig.ConnectionString;
|
var connection = this.Context.CurrentConnectionConfig.ConnectionString;
|
||||||
Check.Exception(Regex.Split(connection,oldDatabaseName).Length > 2, "The user name and password cannot be the same as the database name ");
|
Check.ExceptionEasy(Regex.Split(connection,oldDatabaseName).Length > 2
|
||||||
|
, "The user name and password cannot be the same as the database name ",
|
||||||
|
" 创建数据库失败, 请换一个库名,库名不能 password 或者 username 有重叠 ");
|
||||||
connection = connection.Replace(oldDatabaseName, "mysql");
|
connection = connection.Replace(oldDatabaseName, "mysql");
|
||||||
var newDb = new SqlSugarClient(new ConnectionConfig()
|
var newDb = new SqlSugarClient(new ConnectionConfig()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -996,6 +996,10 @@ namespace SqlSugar
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Other method
|
#region Other method
|
||||||
|
public SqlSugarClient CopyNew()
|
||||||
|
{
|
||||||
|
return new SqlSugarClient(UtilMethods.CopyConfig(this.Ado.Context.CurrentConnectionConfig));
|
||||||
|
}
|
||||||
public DateTime GetDate()
|
public DateTime GetDate()
|
||||||
{
|
{
|
||||||
return this.Context.GetDate();
|
return this.Context.GetDate();
|
||||||
|
|||||||
@@ -762,6 +762,9 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
return ScopedContext.UpdateNav(datas);
|
return ScopedContext.UpdateNav(datas);
|
||||||
}
|
}
|
||||||
|
public SqlSugarClient CopyNew()
|
||||||
|
{
|
||||||
|
return new SqlSugarClient(UtilMethods.CopyConfig(this.Ado.Context.CurrentConnectionConfig));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user