Skip to content

Commit

Permalink
1.Remove unused Object
Browse files Browse the repository at this point in the history
2.Rename EntityMapping,FieldMapping File
  • Loading branch information
279328316 committed Aug 21, 2023
1 parent 6557841 commit b34cdd7
Show file tree
Hide file tree
Showing 21 changed files with 109 additions and 180 deletions.
9 changes: 0 additions & 9 deletions IsFieldOp.txt

This file was deleted.

44 changes: 22 additions & 22 deletions Jc.Core.Database/Data/Provider/DbProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public DbCommand CreateDbCommand(string sql = null)
internal DbCommand GetInsertDbCmd<T>(T dto, List<FieldMapping> piMapList, string subTableArg = null) where T : class, new()
{
DbCommand dbCommand = CreateDbCommand();
TableMapping dtoMapping = DtoMappingHelper.GetDtoMapping<T>();
EntityMapping dtoMapping = EntityMappingHelper.GetMapping<T>();
#region 设置DbCommand
string sqlStr = "Insert into {0} ({1}) values({2})";
string fieldParams = null;
Expand Down Expand Up @@ -234,7 +234,7 @@ public DbCommand CreateDbCommand(string sql = null)
internal DbCommand GetInsertDbCmd<T>(List<T> list, List<FieldMapping> piMapList, string subTableArg = null) where T : class, new()
{
DbCommand dbCommand = CreateDbCommand();
TableMapping dtoDbMapping = DtoMappingHelper.GetDtoMapping<T>();
EntityMapping dtoDbMapping = EntityMappingHelper.GetMapping<T>();
#region 设置DbCommand
string sqlStr = "Insert into {0} ({1}) values{2}";
string fieldParams = null;
Expand Down Expand Up @@ -291,7 +291,7 @@ public DbCommand CreateDbCommand(string sql = null)
internal DbCommand GetImportDbCmd<T>(T dto, List<FieldMapping> piMapList, string subTableArg = null) where T : class, new()
{
DbCommand dbCommand = CreateDbCommand();
TableMapping dtoDbMapping = DtoMappingHelper.GetDtoMapping<T>();
EntityMapping dtoDbMapping = EntityMappingHelper.GetMapping<T>();
#region 设置DbCommand
string sqlStr = "Insert into {0} ({1}) values({2})";
string fieldParams = null;
Expand Down Expand Up @@ -326,7 +326,7 @@ public DbCommand CreateDbCommand(string sql = null)
internal DbCommand GetUpdateDbCmd<T>(T dto, List<FieldMapping> piMapList, string subTableArg = null)
{
DbCommand dbCommand = CreateDbCommand();
TableMapping dtoDbMapping = DtoMappingHelper.GetDtoMapping<T>();
EntityMapping dtoDbMapping = EntityMappingHelper.GetMapping<T>();
#region 设置DbCommand
string sqlStr = "Update {0} set {1} where {2};";
string setParams = null;
Expand Down Expand Up @@ -376,7 +376,7 @@ internal DbCommand GetUpdateDbCmd<T>(T dto, List<FieldMapping> piMapList, string
internal DbCommand GetUpdateDbCmd<T>(T dto, QueryFilter filter, string subTableArg = null)
{
DbCommand dbCommand = CreateDbCommand();
TableMapping dtoDbMapping = DtoMappingHelper.GetDtoMapping<T>();
EntityMapping dtoDbMapping = EntityMappingHelper.GetMapping<T>();
#region 设置DbCommand
string sqlStr = "Update {0} set {1}";

Expand All @@ -396,7 +396,7 @@ internal DbCommand GetUpdateDbCmd<T>(T dto, QueryFilter filter, string subTableA
dbCommand.Parameters.Add(dbParameter);
}
}
List<FieldMapping> piMapList = DtoMappingHelper.GetPiMapList<T>(filter);
List<FieldMapping> piMapList = EntityMappingHelper.GetPiMapList<T>(filter);
foreach (FieldMapping piMap in piMapList)
{
if (piMap == dtoDbMapping.PkField && dtoDbMapping.IsAutoIncrementPk)
Expand Down Expand Up @@ -434,7 +434,7 @@ internal DbCommand GetUpdateDbCmd<T>(T dto, QueryFilter filter, string subTableA
internal DbCommand GetUpdateDbCmd<T>(List<T> list, List<FieldMapping> piMapList, string subTableArg = null)
{
DbCommand dbCommand = CreateDbCommand();
TableMapping dtoDbMapping = DtoMappingHelper.GetDtoMapping<T>();
EntityMapping dtoDbMapping = EntityMappingHelper.GetMapping<T>();
#region 设置DbCommand

StringBuilder strBuilder = new StringBuilder();
Expand Down Expand Up @@ -495,7 +495,7 @@ internal DbCommand GetDeleteDbCmd<T>(T dto, string subTableArg = null)

string sqlStr = "Delete From {0} Where {1}";
string whereParams = null;
TableMapping dtoDbMapping = DtoMappingHelper.GetDtoMapping<T>();
EntityMapping dtoDbMapping = EntityMappingHelper.GetMapping<T>();

DbParameter dbParameter = dbCommand.CreateParameter();
dbParameter.Direction = ParameterDirection.Input;
Expand Down Expand Up @@ -526,7 +526,7 @@ internal DbCommand GetDeleteDbCmd<T>(QueryFilter filter, string subTableArg = nu

string sqlStr = "Delete From {0} ";

TableMapping dtoDbMapping = DtoMappingHelper.GetDtoMapping<T>();
EntityMapping dtoDbMapping = EntityMappingHelper.GetMapping<T>();

if (filter != null && filter.FilterParameters.Count > 0)
{
Expand Down Expand Up @@ -562,7 +562,7 @@ internal DbCommand GetDeleteByIdDbCmd<T>(object pkValue, string subTableArg = nu

string sqlStr = "Delete From {0} Where {1}";
string whereParams = null;
TableMapping dtoDbMapping = DtoMappingHelper.GetDtoMapping<T>();
EntityMapping dtoDbMapping = EntityMappingHelper.GetMapping<T>();

DbParameter dbParameter = dbCommand.CreateParameter();
dbParameter.Direction = ParameterDirection.Input;
Expand Down Expand Up @@ -590,8 +590,8 @@ internal DbCommand GetQueryDbCommand<T>(QueryFilter filter = null, string subTab
DbCommand dbCommand = CreateDbCommand();
string sqlStr = "Select {1} From {0}";
string selectParams = null;
TableMapping dtoDbMapping = DtoMappingHelper.GetDtoMapping<T>();
List<FieldMapping> piMapList = DtoMappingHelper.GetPiMapList<T>(filter);
EntityMapping dtoDbMapping = EntityMappingHelper.GetMapping<T>();
List<FieldMapping> piMapList = EntityMappingHelper.GetPiMapList<T>(filter);
foreach (FieldMapping piMap in piMapList)
{
selectParams += string.IsNullOrEmpty(selectParams) ? piMap.FieldName : $",{piMap.FieldName}";
Expand Down Expand Up @@ -632,8 +632,8 @@ internal DbCommand GetQueryAllFieldDbCommand<T>(QueryFilter filter = null, strin
{
DbCommand dbCommand = CreateDbCommand();
string sqlStr = "Select * From {0}";
TableMapping dtoDbMapping = DtoMappingHelper.GetDtoMapping<T>();
List<FieldMapping> piMapList = DtoMappingHelper.GetPiMapList<T>(filter);
EntityMapping dtoDbMapping = EntityMappingHelper.GetMapping<T>();
List<FieldMapping> piMapList = EntityMappingHelper.GetPiMapList<T>(filter);
if (filter != null && filter.ItemList.Count > 0)
{
sqlStr += filter.FilterSQLString;
Expand Down Expand Up @@ -669,7 +669,7 @@ internal DbCommand GetQueryAllFieldDbCommand<T>(QueryFilter filter = null, strin
internal DbCommand GetQueryByIdDbCommand<T>(object id, List<FieldMapping> piMapList, string subTableArg = null)
{
DbCommand dbCommand = CreateDbCommand();
TableMapping dtoDbMapping = DtoMappingHelper.GetDtoMapping<T>();
EntityMapping dtoDbMapping = EntityMappingHelper.GetMapping<T>();
string sqlStr = "Select {1} From {0} where {2}";
string selectParams = null;
string whereParams = null;
Expand Down Expand Up @@ -702,8 +702,8 @@ internal DbCommand GetSumDbCommand<T>(QueryFilter filter = null, string subTable
DbCommand dbCommand = CreateDbCommand();
string sqlStr = "Select Sum({1}) as Total From {0}";
string selectParams = null;
TableMapping dtoDbMapping = DtoMappingHelper.GetDtoMapping<T>();
FieldMapping piMap = DtoMappingHelper.GetPiMapList<T>(filter).FirstOrDefault();
EntityMapping dtoDbMapping = EntityMappingHelper.GetMapping<T>();
FieldMapping piMap = EntityMappingHelper.GetPiMapList<T>(filter).FirstOrDefault();
if (piMap == null)
{
throw new Exception("求和字段不能为空");
Expand Down Expand Up @@ -742,8 +742,8 @@ internal DbCommand GetMinDbCommand<T>(QueryFilter filter = null, string subTable
DbCommand dbCommand = CreateDbCommand();
string sqlStr = "Select Min({1}) as Total From {0}";
string selectParams = null;
TableMapping dtoDbMapping = DtoMappingHelper.GetDtoMapping<T>();
FieldMapping piMap = DtoMappingHelper.GetPiMapList<T>(filter).FirstOrDefault();
EntityMapping dtoDbMapping = EntityMappingHelper.GetMapping<T>();
FieldMapping piMap = EntityMappingHelper.GetPiMapList<T>(filter).FirstOrDefault();
if (piMap == null)
{
throw new Exception("计算字段不能为空");
Expand Down Expand Up @@ -781,8 +781,8 @@ internal DbCommand GetMaxDbCommand<T>(QueryFilter filter = null, string subTable
DbCommand dbCommand = CreateDbCommand();
string sqlStr = "Select Max({1}) as Total From {0}";
string selectParams = null;
TableMapping dtoDbMapping = DtoMappingHelper.GetDtoMapping<T>();
FieldMapping piMap = DtoMappingHelper.GetPiMapList<T>(filter).FirstOrDefault();
EntityMapping dtoDbMapping = EntityMappingHelper.GetMapping<T>();
FieldMapping piMap = EntityMappingHelper.GetPiMapList<T>(filter).FirstOrDefault();
if (piMap == null)
{
throw new Exception("计算字段不能为空");
Expand Down Expand Up @@ -820,7 +820,7 @@ internal DbCommand GetCountDbCommand<T>(QueryFilter filter, string subTableArg =
DbCommand dbCommand = CreateDbCommand();
string sqlStr = "Select Count(*) as RecCount From {0} {1}";
string queryStr = "";
TableMapping dtoDbMapping = DtoMappingHelper.GetDtoMapping<T>();
EntityMapping dtoDbMapping = EntityMappingHelper.GetMapping<T>();
if (filter != null && filter.ItemList.Count > 0)
{
queryStr = filter.FilterSQLString;
Expand Down
10 changes: 5 additions & 5 deletions Jc.Core.Database/Data/Provider/MsSqlDbProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ public override DbCommand GetQueryRecordsPageDbCommand<T>(QueryFilter filter, st
string queryStr = null;
string orderStr = null;

TableMapping dtoDbMapping = DtoMappingHelper.GetDtoMapping<T>();
List<FieldMapping> piMapList = DtoMappingHelper.GetPiMapList<T>(filter);
EntityMapping dtoDbMapping = EntityMappingHelper.GetMapping<T>();
List<FieldMapping> piMapList = EntityMappingHelper.GetPiMapList<T>(filter);
foreach (FieldMapping piMap in piMapList)
{
selectParams += string.IsNullOrEmpty(selectParams) ? "t2.Num,t1." + piMap.FieldName : ",t1." + piMap.FieldName;
Expand Down Expand Up @@ -137,7 +137,7 @@ public override DbCommand GetQueryRecordsPageDbCommand<T>(QueryFilter filter, st
public override DbCommand GetCheckTableExistsDbCommand<T>(string subTableArg = null)
{
DbCommand dbCommand = CreateDbCommand();
TableMapping dtoDbMapping = DtoMappingHelper.GetDtoMapping<T>();
EntityMapping dtoDbMapping = EntityMappingHelper.GetMapping<T>();
string tableName = dtoDbMapping.GetTableName(subTableArg);
dbCommand.CommandText = $"Select id from dbo.sysobjects where id = object_id(N'[dbo].[{tableName}]')";
return dbCommand;
Expand Down Expand Up @@ -214,8 +214,8 @@ from sys.objects as t
public override string GetCreateTableSql<T>(string subTableArg = null)
{
//表名 查询字段名 主键字段名
TableMapping dtoDbMapping = DtoMappingHelper.GetDtoMapping<T>();
List<FieldMapping> piMapList = DtoMappingHelper.GetPiMapList<T>();
EntityMapping dtoDbMapping = EntityMappingHelper.GetMapping<T>();
List<FieldMapping> piMapList = EntityMappingHelper.GetPiMapList<T>();

string tableName = dtoDbMapping.GetTableName(subTableArg);

Expand Down
10 changes: 5 additions & 5 deletions Jc.Core.Database/Data/Provider/MySqlDbProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ public override DbCommand GetQueryRecordsPageDbCommand<T>(QueryFilter filter, st

string queryStr = null;
string orderStr = null;
TableMapping dtoDbMapping = DtoMappingHelper.GetDtoMapping<T>();
List<FieldMapping> piMapList = DtoMappingHelper.GetPiMapList<T>(filter);
EntityMapping dtoDbMapping = EntityMappingHelper.GetMapping<T>();
List<FieldMapping> piMapList = EntityMappingHelper.GetPiMapList<T>(filter);
foreach (FieldMapping piMap in piMapList)
{
selectParams += string.IsNullOrEmpty(selectParams) ? piMap.FieldName : "," + piMap.FieldName;
Expand Down Expand Up @@ -184,7 +184,7 @@ from information_schema.columns
public override DbCommand GetCheckTableExistsDbCommand<T>(string subTableArg = null)
{
DbCommand dbCommand = CreateDbCommand();
TableMapping dtoDbMapping = DtoMappingHelper.GetDtoMapping<T>();
EntityMapping dtoDbMapping = EntityMappingHelper.GetMapping<T>();
string tableName = dtoDbMapping.GetTableName(subTableArg);
dbCommand.CommandText = $"Select * from information_schema.tables where table_schema = '{DbName}' and table_name ='{tableName}';";
return dbCommand;
Expand All @@ -211,8 +211,8 @@ public override DbCommand GetCheckTableExistsDbCommand(string tableName)
public override string GetCreateTableSql<T>(string subTableArg = null)
{
//表名 查询字段名 主键字段名
TableMapping dtoDbMapping = DtoMappingHelper.GetDtoMapping<T>();
List<FieldMapping> piMapList = DtoMappingHelper.GetPiMapList<T>();
EntityMapping dtoDbMapping = EntityMappingHelper.GetMapping<T>();
List<FieldMapping> piMapList = EntityMappingHelper.GetPiMapList<T>();
string tableName = dtoDbMapping.GetTableName(subTableArg);
StringBuilder sqlBuilder = new StringBuilder();
sqlBuilder.Append($"Create table {tableName}(\r\n");
Expand Down
10 changes: 5 additions & 5 deletions Jc.Core.Database/Data/Provider/PostgreSqlDbProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ public override DbCommand GetQueryRecordsPageDbCommand<T>(QueryFilter filter, st

string queryStr = null;
string orderStr = null;
TableMapping dtoDbMapping = DtoMappingHelper.GetDtoMapping<T>();
List<FieldMapping> piMapList = DtoMappingHelper.GetPiMapList<T>(filter);
EntityMapping dtoDbMapping = EntityMappingHelper.GetMapping<T>();
List<FieldMapping> piMapList = EntityMappingHelper.GetPiMapList<T>(filter);
foreach (FieldMapping piMap in piMapList)
{
selectParams += string.IsNullOrEmpty(selectParams) ? piMap.FieldName : "," + piMap.FieldName;
Expand Down Expand Up @@ -198,7 +198,7 @@ from pg_constraint
public override DbCommand GetCheckTableExistsDbCommand<T>(string subTableArg = null)
{
DbCommand dbCommand = CreateDbCommand();
TableMapping dtoDbMapping = DtoMappingHelper.GetDtoMapping<T>();
EntityMapping dtoDbMapping = EntityMappingHelper.GetMapping<T>();
string tableName = dtoDbMapping.GetTableName(subTableArg);
dbCommand.CommandText = $"Select * from information_schema.tables where table_schema='public' and table_type='BASE TABLE' and table_name='{tableName}';";
return dbCommand;
Expand All @@ -225,8 +225,8 @@ public override DbCommand GetCheckTableExistsDbCommand(string tableName)
public override string GetCreateTableSql<T>(string subTableArg = null)
{
//表名 查询字段名 主键字段名
TableMapping dtoDbMapping = DtoMappingHelper.GetDtoMapping<T>();
List<FieldMapping> piMapList = DtoMappingHelper.GetPiMapList<T>();
EntityMapping dtoDbMapping = EntityMappingHelper.GetMapping<T>();
List<FieldMapping> piMapList = EntityMappingHelper.GetPiMapList<T>();
string tableName = dtoDbMapping.GetTableName(subTableArg);
StringBuilder sqlBuilder = new StringBuilder();
sqlBuilder.Append($"Create table public.{tableName}(\r\n");
Expand Down
10 changes: 5 additions & 5 deletions Jc.Core.Database/Data/Provider/SqliteDbProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ public override DbCommand GetQueryRecordsPageDbCommand<T>(QueryFilter filter, st
string queryStr = null;
string orderStr = null;

TableMapping dtoDbMapping = DtoMappingHelper.GetDtoMapping<T>();
List<FieldMapping> piMapList = DtoMappingHelper.GetPiMapList<T>(filter);
EntityMapping dtoDbMapping = EntityMappingHelper.GetMapping<T>();
List<FieldMapping> piMapList = EntityMappingHelper.GetPiMapList<T>(filter);
foreach (FieldMapping piMap in piMapList)
{
selectParams += string.IsNullOrEmpty(selectParams) ? piMap.FieldName : "," + piMap.FieldName;
Expand Down Expand Up @@ -169,7 +169,7 @@ public override DbCommand GetFieldListDbCommand(string tableName)
public override DbCommand GetCheckTableExistsDbCommand<T>(string subTableArg = null)
{
DbCommand dbCommand = CreateDbCommand();
TableMapping dtoDbMapping = DtoMappingHelper.GetDtoMapping<T>();
EntityMapping dtoDbMapping = EntityMappingHelper.GetMapping<T>();
string tableName = dtoDbMapping.GetTableName(subTableArg);
dbCommand.CommandText = $"select * from sqlite_master where type='table' and name = '{tableName}';";
return dbCommand;
Expand All @@ -196,8 +196,8 @@ public override DbCommand GetCheckTableExistsDbCommand(string tableName)
public override string GetCreateTableSql<T>(string subTableArg = null)
{
//表名 查询字段名 主键字段名
TableMapping dtoDbMapping = DtoMappingHelper.GetDtoMapping<T>();
List<FieldMapping> piMapList = DtoMappingHelper.GetPiMapList<T>();
EntityMapping dtoDbMapping = EntityMappingHelper.GetMapping<T>();
List<FieldMapping> piMapList = EntityMappingHelper.GetPiMapList<T>();
string tableName = dtoDbMapping.GetTableName(subTableArg);
StringBuilder sqlBuilder = new StringBuilder();
sqlBuilder.Append($"Create table {tableName}(\r\n");
Expand Down
4 changes: 2 additions & 2 deletions Jc.Core.Database/Data/Query/DataSetExpand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public static class DataSetExpand
List<T> list = new List<T>();
if (dt != null && dt.Rows.Count > 0)
{
TableMapping dtoMapping = DtoMappingHelper.GetDtoMapping<T>();
EntityMapping dtoMapping = EntityMappingHelper.GetMapping<T>();
foreach (DataRow dr in dt.Rows)
{
list.Add(dr.ToEntity<T>());
Expand All @@ -32,7 +32,7 @@ public static class DataSetExpand
/// <returns></returns>
public static T ToEntity<T>(this DataRow dr) where T : class, new()
{
TableMapping dtoMapping = DtoMappingHelper.GetDtoMapping<T>();
EntityMapping dtoMapping = EntityMappingHelper.GetMapping<T>();
if (dtoMapping.EntityConvertor == null)
{
dtoMapping.EntityConvertor = EntityConvertor.CreateEntityConvertor<T>(); //存入dtoMapping中,缓存起来
Expand Down
2 changes: 1 addition & 1 deletion Jc.Core.Database/Data/Query/EntityConvertor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public static void ILGenerateSetValueMethodContent<T>(ILGenerator il)
//begin try
Label tryLabel = il.BeginExceptionBlock();

List<FieldMapping> piMapList = DtoMappingHelper.GetPiMapList<T>();
List<FieldMapping> piMapList = EntityMappingHelper.GetPiMapList<T>();
foreach (FieldMapping piMap in piMapList)
{
if (piMap.IsIgnore || piMap.Pi.SetMethod == null)
Expand Down
Loading

0 comments on commit b34cdd7

Please sign in to comment.