mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-19 10:08:19 +08:00
Update CodeFirst
This commit is contained in:
@@ -147,7 +147,7 @@ namespace SqlSugar
|
||||
}
|
||||
public virtual void ExistLogic(EntityInfo entityInfo)
|
||||
{
|
||||
if (entityInfo.Columns.HasValue())
|
||||
if (entityInfo.Columns.HasValue()&&entityInfo.IsDisabledUpdateAll==false)
|
||||
{
|
||||
//Check.Exception(entityInfo.Columns.Where(it => it.IsPrimarykey).Count() > 1, "Multiple primary keys do not support modifications");
|
||||
|
||||
@@ -184,10 +184,13 @@ namespace SqlSugar
|
||||
this.Context.DbMaintenance.AddColumn(tableName, EntityColumnToDbColumn(entityInfo, tableName, item));
|
||||
isChange = true;
|
||||
}
|
||||
foreach (var item in dropColumns)
|
||||
if (entityInfo.IsDisabledDelete)
|
||||
{
|
||||
this.Context.DbMaintenance.DropColumn(tableName, item.DbColumnName);
|
||||
isChange = true;
|
||||
foreach (var item in dropColumns)
|
||||
{
|
||||
this.Context.DbMaintenance.DropColumn(tableName, item.DbColumnName);
|
||||
isChange = true;
|
||||
}
|
||||
}
|
||||
foreach (var item in alterColumns)
|
||||
{
|
||||
|
@@ -28,6 +28,8 @@ namespace SqlSugar
|
||||
var sugarTable = (SugarTable)sugarAttributeInfo;
|
||||
result.DbTableName = sugarTable.TableName;
|
||||
result.TableDescription = sugarTable.TableDescription;
|
||||
result.IsDisabledUpdateAll = sugarTable.IsDisabledUpdateAll;
|
||||
result.IsDisabledDelete = sugarTable.IsDisabledDelete;
|
||||
}
|
||||
if (this.Context.Context.CurrentConnectionConfig.ConfigureExternalServices != null && this.Context.CurrentConnectionConfig.ConfigureExternalServices.EntityNameService != null) {
|
||||
if (result.DbTableName == null)
|
||||
|
@@ -15,5 +15,7 @@ namespace SqlSugar
|
||||
public string TableDescription { get; set; }
|
||||
public Type Type { get; set; }
|
||||
public List<EntityColumnInfo> Columns { get; set; }
|
||||
public bool IsDisabledDelete { get; set; }
|
||||
public bool IsDisabledUpdateAll { get; set; }
|
||||
}
|
||||
}
|
||||
|
@@ -11,6 +11,9 @@ namespace SqlSugar
|
||||
private SugarTable() { }
|
||||
public string TableName { get; set; }
|
||||
public string TableDescription { get; set; }
|
||||
public bool IsDisabledDelete { get; set; }
|
||||
public bool IsDisabledUpdateAll { get; set; }
|
||||
|
||||
public SugarTable(string tableName) {
|
||||
this.TableName = tableName;
|
||||
}
|
||||
@@ -19,6 +22,13 @@ namespace SqlSugar
|
||||
this.TableName = tableName;
|
||||
this.TableDescription = tableDescription;
|
||||
}
|
||||
|
||||
public SugarTable(string tableName, string tableDescription,bool isDisabledDelete)
|
||||
{
|
||||
this.TableName = tableName;
|
||||
this.TableDescription = tableDescription;
|
||||
this.IsDisabledDelete = isDisabledDelete;
|
||||
}
|
||||
}
|
||||
[AttributeUsage(AttributeTargets.Property , Inherited = true)]
|
||||
public class SugarColumn : Attribute
|
||||
|
@@ -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.0.2.6")]
|
||||
[assembly: AssemblyFileVersion("5.0.2.6")]
|
||||
[assembly: AssemblyVersion("5.0.2.7")]
|
||||
[assembly: AssemblyFileVersion("5.0.2.7")]
|
||||
|
@@ -9,7 +9,7 @@ namespace SqlSugar
|
||||
{
|
||||
public override void ExistLogic(EntityInfo entityInfo)
|
||||
{
|
||||
if (entityInfo.Columns.HasValue())
|
||||
if (entityInfo.Columns.HasValue()&&entityInfo.IsDisabledUpdateAll==false)
|
||||
{
|
||||
Check.Exception(entityInfo.Columns.Where(it => it.IsPrimarykey).Count() > 1, "Use Code First ,The primary key must not exceed 1");
|
||||
|
||||
|
Reference in New Issue
Block a user