@ -62,7 +62,7 @@ namespace SqlSugar
{
{
get
get
{
{
return "CREATE INDEX Index_{0}_{2} ON {0}({1})" ;
return "CREATE {3} INDEX Index_{0}_{2} ON {0}({1})" ;
}
}
}
}
protected override string AddDefaultValueSql
protected override string AddDefaultValueSql
@ -271,9 +271,9 @@ namespace SqlSugar
}
}
return base . AddColumn ( tableName , columnInfo ) ;
return base . AddColumn ( tableName , columnInfo ) ;
}
}
public override bool CreateIndex ( string tableName , string [ ] columnNames )
public override bool CreateIndex ( string tableName , string [ ] columnNames , bool isUnique = false )
{
{
string sql = string . Format ( CreateIndexSql , tableName , string . Join ( "," , columnNames ) , string . Join ( "_" , columnNames . Select ( it = > ( it + "abc" ) . Substring ( 0 , 3 ) ) ) ) ;
string sql = string . Format ( CreateIndexSql , tableName , string . Join ( "," , columnNames ) , string . Join ( "_" , columnNames . Select ( it = > ( it + "abc" ) . Substring ( 0 , 3 ) ) ) , isUnique ? "UNIQUE" : "" ) ;
this . Context . Ado . ExecuteCommand ( sql ) ;
this . Context . Ado . ExecuteCommand ( sql ) ;
return true ;
return true ;
}
}
@ -360,7 +360,7 @@ namespace SqlSugar
string sql = "select * from " + SqlBuilder . GetTranslationTableName ( tableName ) + " WHERE 1=2 " ;
string sql = "select * from " + SqlBuilder . GetTranslationTableName ( tableName ) + " WHERE 1=2 " ;
var oldIsEnableLog = this . Context . Ado . IsEnableLogEvent ;
var oldIsEnableLog = this . Context . Ado . IsEnableLogEvent ;
this . Context . Ado . IsEnableLogEvent = false ;
this . Context . Ado . IsEnableLogEvent = false ;
using ( DbDataReader reader = ( DbDataReader ) this . Context . Ado . GetDataReader ( sql ) )
using ( DbDataReader reader = ( DbDataReader ) this . Context . Ado . GetDataReader ( sql ) )
{
{
this . Context . Ado . IsEnableLogEvent = oldIsEnableLog ;
this . Context . Ado . IsEnableLogEvent = oldIsEnableLog ;
List < DbColumnInfo > result = new List < DbColumnInfo > ( ) ;
List < DbColumnInfo > result = new List < DbColumnInfo > ( ) ;
@ -371,8 +371,8 @@ namespace SqlSugar
{
{
TableName = tableName ,
TableName = tableName ,
DataType = row [ "DataType" ] . ToString ( ) . Replace ( "System." , "" ) . Trim ( ) ,
DataType = row [ "DataType" ] . ToString ( ) . Replace ( "System." , "" ) . Trim ( ) ,
IsNullable = ( bool ) row [ "AllowDBNull" ] ,
IsNullable = ( bool ) row [ "AllowDBNull" ] ,
IsIdentity = ( bool ) row [ "IsIdentity" ] ,
IsIdentity = ( bool ) row [ "IsIdentity" ] ,
ColumnDescription = GetFieldComment ( tableName , row [ "ColumnName" ] . ToString ( ) ) ,
ColumnDescription = GetFieldComment ( tableName , row [ "ColumnName" ] . ToString ( ) ) ,
DbColumnName = row [ "ColumnName" ] . ToString ( ) ,
DbColumnName = row [ "ColumnName" ] . ToString ( ) ,
//DefaultValue = row["defaultValue"].ToString(),
//DefaultValue = row["defaultValue"].ToString(),
@ -426,7 +426,7 @@ namespace SqlSugar
var comments = this . Context . Utilities . GetReflectionInoCacheInstance ( ) . GetOrCreate ( cacheKey ,
var comments = this . Context . Utilities . GetReflectionInoCacheInstance ( ) . GetOrCreate ( cacheKey ,
( ) = >
( ) = >
{
{
string sql = "SELECT TVNAME AS TableName, COLNAME,COMMENT$ AS ColumnDescription from SYSCOLUMNCOMMENTS WHERE TVNAME='" + tableName . ToUpper ( ) + "' ORDER BY TVNAME" ;
string sql = "SELECT TVNAME AS TableName, COLNAME,COMMENT$ AS ColumnDescription from SYSCOLUMNCOMMENTS WHERE TVNAME='" + tableName . ToUpper ( ) + "' ORDER BY TVNAME" ;
var oldIsEnableLog = this . Context . Ado . IsEnableLogEvent ;
var oldIsEnableLog = this . Context . Ado . IsEnableLogEvent ;
this . Context . Ado . IsEnableLogEvent = false ;
this . Context . Ado . IsEnableLogEvent = false ;
var pks = this . Context . Ado . SqlQuery < DbColumnInfo > ( sql ) ;
var pks = this . Context . Ado . SqlQuery < DbColumnInfo > ( sql ) ;