mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-19 10:08:19 +08:00
Code optimization
This commit is contained in:
@@ -48,7 +48,7 @@ namespace SqlSugar
|
||||
}
|
||||
public virtual void InitTables(string entitiesNamespace)
|
||||
{
|
||||
var types = ReflectionCore.Load(entitiesNamespace).GetTypes();
|
||||
var types = Assembly.Load(entitiesNamespace).GetTypes();
|
||||
InitTables(types);
|
||||
}
|
||||
public virtual void InitTables(params string[] entitiesNamespaces)
|
||||
|
@@ -82,36 +82,4 @@ namespace SqlSugar
|
||||
return method.ReflectedType;
|
||||
}
|
||||
}
|
||||
public static class AdoCore
|
||||
{
|
||||
public static List<DbColumnInfo> GetColumnInfosByTableName(string tableName, DbDataReader dataReader)
|
||||
{
|
||||
List<DbColumnInfo> result = new List<DbColumnInfo>();
|
||||
var schemaTable = dataReader.GetSchemaTable();
|
||||
foreach (DataRow row in schemaTable.Rows)
|
||||
{
|
||||
DbColumnInfo column = new DbColumnInfo()
|
||||
{
|
||||
TableName = tableName,
|
||||
DataType = row["DataTypeName"].ToString().Trim(),
|
||||
IsNullable = (bool)row["AllowDBNull"],
|
||||
IsIdentity = (bool)row["IsAutoIncrement"],
|
||||
ColumnDescription = null,
|
||||
DbColumnName = row["ColumnName"].ToString(),
|
||||
DefaultValue = row["defaultValue"].ToString(),
|
||||
IsPrimarykey = (bool)row["IsKey"],
|
||||
Length = Convert.ToInt32(row["ColumnSize"])
|
||||
};
|
||||
result.Add(column);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
public static class ReflectionCore
|
||||
{
|
||||
public static Assembly Load(string name)
|
||||
{
|
||||
return Assembly.Load(name);
|
||||
}
|
||||
}
|
||||
}
|
@@ -8,7 +8,7 @@ namespace SqlSugar
|
||||
{
|
||||
public class InstanceFactory
|
||||
{
|
||||
static Assembly assembly = ReflectionCore.Load(PubConst.AssemblyName);
|
||||
static Assembly assembly = Assembly.Load(PubConst.AssemblyName);
|
||||
static Dictionary<string, Type> typeCache = new Dictionary<string, Type>();
|
||||
|
||||
#region Queryable
|
||||
|
@@ -181,7 +181,25 @@ namespace SqlSugar
|
||||
using (DbDataReader reader = (SQLiteDataReader)this.Context.Ado.GetDataReader(sql))
|
||||
{
|
||||
this.Context.Ado.IsEnableLogEvent = oldIsEnableLog;
|
||||
return AdoCore.GetColumnInfosByTableName(tableName, reader);
|
||||
List<DbColumnInfo> result = new List<DbColumnInfo>();
|
||||
var schemaTable = reader.GetSchemaTable();
|
||||
foreach (DataRow row in schemaTable.Rows)
|
||||
{
|
||||
DbColumnInfo column = new DbColumnInfo()
|
||||
{
|
||||
TableName = tableName,
|
||||
DataType = row["DataTypeName"].ToString().Trim(),
|
||||
IsNullable = (bool)row["AllowDBNull"],
|
||||
IsIdentity = (bool)row["IsAutoIncrement"],
|
||||
ColumnDescription = null,
|
||||
DbColumnName = row["ColumnName"].ToString(),
|
||||
DefaultValue = row["defaultValue"].ToString(),
|
||||
IsPrimarykey = (bool)row["IsKey"],
|
||||
Length = Convert.ToInt32(row["ColumnSize"])
|
||||
};
|
||||
result.Add(column);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
});
|
||||
|
@@ -71,7 +71,7 @@
|
||||
<Compile Include="Abstract\FilterProvider\FilterProvider.cs" />
|
||||
<Compile Include="Abstract\InsertableProvider\InsertableProvider.cs" />
|
||||
<Compile Include="Abstract\DeleteProvider\DeleteableProvider.cs" />
|
||||
<Compile Include="CompatibleNetCore\CompatibleExtensions.cs" />
|
||||
<Compile Include="Common\ReflectionExtensions.cs" />
|
||||
<Compile Include="Realization\MySql\CodeFirst\MySqlCodeFirst.cs" />
|
||||
<Compile Include="Realization\MySql\DbFirst\MySqlDbFirst.cs" />
|
||||
<Compile Include="Realization\MySql\DbMaintenance\MySqlDbMaintenance.cs" />
|
||||
|
Reference in New Issue
Block a user