mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-20 10:38:09 +08:00
Update CodeFirst
This commit is contained in:
@@ -147,7 +147,7 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
public virtual void ExistLogic(EntityInfo entityInfo)
|
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");
|
//Check.Exception(entityInfo.Columns.Where(it => it.IsPrimarykey).Count() > 1, "Multiple primary keys do not support modifications");
|
||||||
|
|
||||||
@@ -184,11 +184,14 @@ namespace SqlSugar
|
|||||||
this.Context.DbMaintenance.AddColumn(tableName, EntityColumnToDbColumn(entityInfo, tableName, item));
|
this.Context.DbMaintenance.AddColumn(tableName, EntityColumnToDbColumn(entityInfo, tableName, item));
|
||||||
isChange = true;
|
isChange = true;
|
||||||
}
|
}
|
||||||
|
if (entityInfo.IsDisabledDelete)
|
||||||
|
{
|
||||||
foreach (var item in dropColumns)
|
foreach (var item in dropColumns)
|
||||||
{
|
{
|
||||||
this.Context.DbMaintenance.DropColumn(tableName, item.DbColumnName);
|
this.Context.DbMaintenance.DropColumn(tableName, item.DbColumnName);
|
||||||
isChange = true;
|
isChange = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
foreach (var item in alterColumns)
|
foreach (var item in alterColumns)
|
||||||
{
|
{
|
||||||
this.Context.DbMaintenance.UpdateColumn(tableName, EntityColumnToDbColumn(entityInfo, tableName, item));
|
this.Context.DbMaintenance.UpdateColumn(tableName, EntityColumnToDbColumn(entityInfo, tableName, item));
|
||||||
|
@@ -28,6 +28,8 @@ namespace SqlSugar
|
|||||||
var sugarTable = (SugarTable)sugarAttributeInfo;
|
var sugarTable = (SugarTable)sugarAttributeInfo;
|
||||||
result.DbTableName = sugarTable.TableName;
|
result.DbTableName = sugarTable.TableName;
|
||||||
result.TableDescription = sugarTable.TableDescription;
|
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 (this.Context.Context.CurrentConnectionConfig.ConfigureExternalServices != null && this.Context.CurrentConnectionConfig.ConfigureExternalServices.EntityNameService != null) {
|
||||||
if (result.DbTableName == null)
|
if (result.DbTableName == null)
|
||||||
|
@@ -15,5 +15,7 @@ namespace SqlSugar
|
|||||||
public string TableDescription { get; set; }
|
public string TableDescription { get; set; }
|
||||||
public Type Type { get; set; }
|
public Type Type { get; set; }
|
||||||
public List<EntityColumnInfo> Columns { 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() { }
|
private SugarTable() { }
|
||||||
public string TableName { get; set; }
|
public string TableName { get; set; }
|
||||||
public string TableDescription { get; set; }
|
public string TableDescription { get; set; }
|
||||||
|
public bool IsDisabledDelete { get; set; }
|
||||||
|
public bool IsDisabledUpdateAll { get; set; }
|
||||||
|
|
||||||
public SugarTable(string tableName) {
|
public SugarTable(string tableName) {
|
||||||
this.TableName = tableName;
|
this.TableName = tableName;
|
||||||
}
|
}
|
||||||
@@ -19,6 +22,13 @@ namespace SqlSugar
|
|||||||
this.TableName = tableName;
|
this.TableName = tableName;
|
||||||
this.TableDescription = tableDescription;
|
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)]
|
[AttributeUsage(AttributeTargets.Property , Inherited = true)]
|
||||||
public class SugarColumn : Attribute
|
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
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("5.0.2.6")]
|
[assembly: AssemblyVersion("5.0.2.7")]
|
||||||
[assembly: AssemblyFileVersion("5.0.2.6")]
|
[assembly: AssemblyFileVersion("5.0.2.7")]
|
||||||
|
@@ -9,7 +9,7 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
public override void ExistLogic(EntityInfo entityInfo)
|
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");
|
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