mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-23 22:11:36 +08:00
Update unit test
This commit is contained in:
parent
bb76c60954
commit
70163e841e
@ -48,8 +48,17 @@ namespace OrmTest
|
||||
db.CodeFirst.InitTables<UnitGe>();
|
||||
db.Insertable(new UnitGe() { geometry1 = "POINT (20 180)" }).ExecuteCommand();
|
||||
var gelist=db.Queryable<UnitGe>().Select(it=>new { geometry1 = it.geometry1.ToString()}).ToList();
|
||||
if (Db.DbMaintenance.IsAnyTable("User", false))
|
||||
Db.DbMaintenance.DropTable("User");
|
||||
db.CodeFirst.InitTables<User>();
|
||||
}
|
||||
public class User
|
||||
{
|
||||
[SugarColumn(IndexGroupNameList =new string[] { "index"})]
|
||||
public int key { get; set; }
|
||||
[SugarColumn(UniqueGroupNameList = new string[] { "index" })]
|
||||
public int key2 { get; set; }
|
||||
}
|
||||
|
||||
public class UnitGe
|
||||
{
|
||||
[SugarColumn(ColumnDataType = "geometry")]
|
||||
|
@ -315,13 +315,17 @@ namespace SqlSugar
|
||||
}
|
||||
public virtual bool CreateIndex(string tableName, string[] columnNames, bool isUnique=false)
|
||||
{
|
||||
string sql = string.Format(CreateIndexSql,tableName,string.Join(",",columnNames), string.Join("_", columnNames) + this.Context.CurrentConnectionConfig.IndexSuffix, isUnique ? "UNIQUE" : "");
|
||||
string sql = string.Format(CreateIndexSql,this.SqlBuilder.GetTranslationTableName(tableName),string.Join(",",columnNames.Select(it=>this.SqlBuilder.GetTranslationColumnName(it))), string.Join("_", columnNames) + this.Context.CurrentConnectionConfig.IndexSuffix, isUnique ? "UNIQUE" : "");
|
||||
sql = sql.Replace("_" + this.SqlBuilder.SqlTranslationLeft, "_");
|
||||
sql = sql.Replace( this.SqlBuilder.SqlTranslationRight+"_", "_");
|
||||
this.Context.Ado.ExecuteCommand(sql);
|
||||
return true;
|
||||
}
|
||||
public virtual bool CreateUniqueIndex(string tableName, string[] columnNames)
|
||||
{
|
||||
string sql = string.Format(CreateIndexSql, tableName, string.Join(",", columnNames), string.Join("_", columnNames) + this.Context.CurrentConnectionConfig.IndexSuffix + "_Unique","UNIQUE" );
|
||||
string sql = string.Format(CreateIndexSql, this.SqlBuilder.GetTranslationTableName(tableName), string.Join(",", columnNames.Select(it => this.SqlBuilder.GetTranslationColumnName(it))), string.Join("_", columnNames) + this.Context.CurrentConnectionConfig.IndexSuffix + "_Unique","UNIQUE" );
|
||||
sql = sql.Replace("_" + this.SqlBuilder.SqlTranslationLeft, "_");
|
||||
sql = sql.Replace(this.SqlBuilder.SqlTranslationRight + "_", "_");
|
||||
this.Context.Ado.ExecuteCommand(sql);
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user