mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2026-02-25 21:22:55 +08:00
Update MySql
This commit is contained in:
@@ -6,12 +6,13 @@ using System.Text;
|
||||
|
||||
namespace OrmTest.Demo
|
||||
{
|
||||
[SugarTable("CodeTable", " CodeTable test ")]
|
||||
public class CodeTable
|
||||
{
|
||||
|
||||
[SugarColumn(IsNullable =false ,IsPrimaryKey =true,IsIdentity =true)]
|
||||
[SugarColumn(IsNullable =false ,IsPrimaryKey =true,IsIdentity =true,ColumnDescription ="test")]
|
||||
public int Id { get; set; }
|
||||
[SugarColumn(Length = 21,OldColumnName = "Name2")]
|
||||
[SugarColumn(Length = 21,OldColumnName = "Name2",ColumnDescription ="name")]
|
||||
public string Name{ get; set; }
|
||||
[SugarColumn(IsNullable = true,Length =11)]
|
||||
public string IsOk { get; set; }
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace SqlSugar
|
||||
public SugarTable(string tableName,string tableDescription)
|
||||
{
|
||||
this.TableName = tableName;
|
||||
this.TableDescription = tableName;
|
||||
this.TableDescription = tableDescription;
|
||||
}
|
||||
}
|
||||
[AttributeUsage(AttributeTargets.Property , Inherited = true)]
|
||||
|
||||
@@ -67,5 +67,10 @@ namespace SqlSugar
|
||||
if (item.IsPrimarykey)
|
||||
this.Context.DbMaintenance.AddPrimaryKey(tableName, item.DbColumnName);
|
||||
}
|
||||
|
||||
internal DbColumnInfo GetEntityColumnToDbColumn(EntityInfo entity, string dbTableName, EntityColumnInfo item)
|
||||
{
|
||||
return EntityColumnToDbColumn(entity,dbTableName,item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -249,6 +249,22 @@ namespace SqlSugar
|
||||
this.Context.Ado.ExecuteCommand(sql);
|
||||
return true;
|
||||
}
|
||||
public override bool AddRemark(EntityInfo entity)
|
||||
{
|
||||
var db = this.Context;
|
||||
db.DbMaintenance.AddTableRemark(entity.DbTableName, entity.TableDescription);
|
||||
List<EntityColumnInfo> columns = entity.Columns.Where(it => it.IsIgnore == false).ToList();
|
||||
foreach (var item in columns)
|
||||
{
|
||||
if (item.ColumnDescription != null)
|
||||
{
|
||||
var mySqlCodeFirst = this.Context.CodeFirst as MySqlCodeFirst;
|
||||
string sql = GetUpdateColumnSql(entity.DbTableName, mySqlCodeFirst.GetEntityColumnToDbColumn(entity, entity.DbTableName, item))+" "+(item.IsIdentity? "AUTO_INCREMENT" : "")+" " + " COMMENT '" + item.ColumnDescription + "'";
|
||||
db.Ado.ExecuteCommand(sql);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
protected override string GetCreateTableSql(string tableName, List<DbColumnInfo> columns)
|
||||
{
|
||||
List<string> columnArray = new List<string>();
|
||||
@@ -303,6 +319,7 @@ namespace SqlSugar
|
||||
Check.ThrowNotSupportedException("MySql BackupDataBase NotSupported");
|
||||
return false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user