mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-23 22:11:36 +08:00
Update access
This commit is contained in:
parent
f35df4222d
commit
da635e9a8f
Binary file not shown.
@ -437,9 +437,49 @@ namespace SqlSugar.Access
|
||||
}
|
||||
public override List<DbColumnInfo> GetColumnInfosByTableName(string tableName, bool isCache = true)
|
||||
{
|
||||
tableName = SqlBuilder.GetNoTranslationColumnName(tableName);
|
||||
var result= base.GetColumnInfosByTableName(tableName, isCache);
|
||||
return result;
|
||||
List<DbColumnInfo> columns = new List<DbColumnInfo>();
|
||||
var dt = this.Context.Ado.GetDataTable("select top 8 * from " +this.SqlBuilder.GetTranslationTableName(tableName));
|
||||
var oleDb = (this.Context.Ado.Connection as OleDbConnection);
|
||||
DataTable columnTable = oleDb.GetOleDbSchemaTable(OleDbSchemaGuid.Columns, new object[] { null, null,tableName, null });
|
||||
DataTable Pk = oleDb.GetOleDbSchemaTable(OleDbSchemaGuid.Primary_Keys, new string[] { null, null, tableName });
|
||||
foreach (DataRow dr in columnTable.Rows)
|
||||
{
|
||||
DbColumnInfo info = new DbColumnInfo();
|
||||
info.TableName = tableName;
|
||||
info.DbColumnName = dr["COLUMN_NAME"] + "";
|
||||
info.IsNullable = Convert.ToBoolean(dr["IS_NULLABLE"]);
|
||||
info.DataType = dt.Columns[info.DbColumnName].DataType.Name;
|
||||
if (info.DataType.EqualCase( "int32"))
|
||||
{
|
||||
info.DataType = "int";
|
||||
}
|
||||
else if (info.DataType.EqualCase("int64"))
|
||||
{
|
||||
info.DataType = "long";
|
||||
}
|
||||
if (info.DataType.EqualCase("string") )
|
||||
{
|
||||
info.Length = dr["CHARACTER_MAXIMUM_LENGTH"].ObjToInt();
|
||||
}
|
||||
if (info.DataType.EqualCase("Decimal"))
|
||||
{
|
||||
info.Length = dr["numeric_precision"].ObjToInt();
|
||||
info.Scale=info.DecimalDigits = dr["numeric_scale"].ObjToInt();
|
||||
}
|
||||
foreach (DataRow pkRow in Pk.Rows)
|
||||
{
|
||||
if (pkRow["COLUMN_NAME"].ObjToString() == dr["COLUMN_NAME"].ObjToString())
|
||||
{
|
||||
info.IsPrimarykey = true;
|
||||
if (info.DataType == "int")
|
||||
{
|
||||
info.IsIdentity = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
columns.Add(info);
|
||||
}
|
||||
return columns;
|
||||
}
|
||||
public override bool RenameColumn(string tableName, string oldColumnName, string newColumnName)
|
||||
{
|
||||
|
@ -8,6 +8,27 @@ namespace SqlSugar.Access
|
||||
{
|
||||
public class AccessInsertBuilder : InsertBuilder
|
||||
{
|
||||
public override string SqlTemplate
|
||||
{
|
||||
get
|
||||
{
|
||||
if (IsReturnIdentity)
|
||||
{
|
||||
return @"INSERT INTO {0}
|
||||
({1})
|
||||
VALUES
|
||||
({2}) ;";
|
||||
}
|
||||
else
|
||||
{
|
||||
return @"INSERT INTO {0}
|
||||
({1})
|
||||
VALUES
|
||||
({2}) ;";
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
public override string ToSqlString()
|
||||
{
|
||||
if (IsNoInsertNull)
|
||||
|
@ -400,7 +400,14 @@ namespace SqlSugar
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return properyTypeName != dataType;
|
||||
if (properyTypeName == null || dataType == null)
|
||||
{
|
||||
return properyTypeName != dataType;
|
||||
}
|
||||
else
|
||||
{
|
||||
return properyTypeName.ToLower() != dataType.ToLower();
|
||||
}
|
||||
}
|
||||
private static string GetType(string name)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user