Update MySql

This commit is contained in:
sunkaixuan
2018-11-11 15:00:31 +08:00
parent 633e513f57
commit 5dde9dbcf7
4 changed files with 26 additions and 3 deletions

View File

@@ -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; }

View File

@@ -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)]

View File

@@ -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);
}
}
}

View File

@@ -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
}
}