diff --git a/Hadoop/ZKLT.Hadoop/TableService.cs b/Hadoop/ZKLT.Hadoop/TableService.cs
index 9adae70..e1f7afd 100644
--- a/Hadoop/ZKLT.Hadoop/TableService.cs
+++ b/Hadoop/ZKLT.Hadoop/TableService.cs
@@ -15,6 +15,42 @@ namespace ZKLT.Hadoop
{
public class TableService : ITableService
{
+ ///
+ /// 合并条件
+ ///
+ /// 表
+ /// 条件
+ /// 数据
+ /// 命令
+ /// 参数
+ private void MergeWhere(HDP_Table table, Dictionary? where, Dictionary? row, StringBuilder command, Dictionary param)
+ {
+ //执行条件
+ StringBuilder _wherestr = new StringBuilder();
+ _wherestr.Append("WHERE 1 = 1");
+ if (where != null && where.Count > 0)
+ {
+ for (var i = 0; i < table.Columns!.Length; i++)
+ {
+ var _column = table.Columns[i];
+ if (where.ContainsKey(_column.Key!))
+ {
+ switch (where[_column.Key!])
+ {
+ case HDP_WhereType.LIKE:
+ _wherestr.Append($@" AND `{_column.Key!}` {where[_column.Key!]} CONCAT('%',@{_column.Key!},'%')");
+ break;
+ default:
+ _wherestr.Append($@" AND `{_column.Key!}` {where[_column.Key!]} @{_column.Key!}");
+ break;
+ }
+ param.Add(_column.Key!, row![_column.Key!]);
+ }
+ }
+ command.AppendLine(_wherestr.ToString());
+ }
+ }
+
///
/// 同步结构
///
@@ -398,26 +434,7 @@ namespace ZKLT.Hadoop
_command.AppendLine(_colstr.ToString());
//执行条件
- StringBuilder _wherestr = new StringBuilder();
- _wherestr.Append("WHERE 1 = 1");
- for (var i = 0; i < table.Columns.Length; i++)
- {
- var _column = table.Columns[i];
- if (where.ContainsKey(_column.Key!))
- {
- switch (where[_column.Key!])
- {
- case HDP_WhereType.LIKE:
- _wherestr.Append($@" AND `{_column.Key!}` {where[_column.Key!]} '%' + @{_column.Key!} + '%'");
- break;
- default:
- _wherestr.Append($@" AND `{_column.Key!}` {where[_column.Key!]} @{_column.Key!}");
- break;
- }
- _params.Add(_column.Key!, row[_column.Key!]);
- }
- }
- _command.AppendLine(_wherestr.ToString());
+ MergeWhere(table, where, row, _command, _params);
var _result = _connection.Execute(HDP_CommandAction.ConvertCommand(_command.ToString(), row), _params);
_connection.Close();
@@ -475,27 +492,7 @@ namespace ZKLT.Hadoop
Dictionary _params = new Dictionary();
_command.AppendLine(@$"DELETE FROM `{table.Key}`");
- //执行条件
- StringBuilder _wherestr = new StringBuilder();
- _wherestr.Append("WHERE 1 = 1");
- for (var i = 0; i < table.Columns.Length; i++)
- {
- var _column = table.Columns[i];
- if (where.ContainsKey(_column.Key!))
- {
- switch (where[_column.Key!])
- {
- case HDP_WhereType.LIKE:
- _wherestr.Append($@" AND `{_column.Key!}` {where[_column.Key!]} '%' + @{_column.Key!} + '%'");
- break;
- default:
- _wherestr.Append($@" AND `{_column.Key!}` {where[_column.Key!]} @{_column.Key!}");
- break;
- }
- _params.Add(_column.Key!, row[_column.Key!]);
- }
- }
- _command.AppendLine(_wherestr.ToString());
+ MergeWhere(table, where, row, _command, _params);
var _result = _connection.Execute(HDP_CommandAction.ConvertCommand(_command.ToString(), row), _params);
_connection.Close();
@@ -554,26 +551,7 @@ namespace ZKLT.Hadoop
_command.AppendLine(@$"SELECT * FROM `{table.Key}`");
//执行条件
- StringBuilder _wherestr = new StringBuilder();
- _wherestr.Append("WHERE 1 = 1");
- for (var i = 0; i < table.Columns.Length; i++)
- {
- var _column = table.Columns[i];
- if (where.ContainsKey(_column.Key!))
- {
- switch (where[_column.Key!])
- {
- case HDP_WhereType.LIKE:
- _wherestr.Append($@" AND `{_column.Key!}` {where[_column.Key!]} '%' + @{_column.Key!} + '%'");
- break;
- default:
- _wherestr.Append($@" AND `{_column.Key!}` {where[_column.Key!]} @{_column.Key!}");
- break;
- }
- _params.Add(_column.Key!, row[_column.Key!]);
- }
- }
- _command.AppendLine(_wherestr.ToString());
+ MergeWhere(table, where, row, _command, _params);
var _result = _connection.Query(HDP_CommandAction.ConvertCommand(_command.ToString(), row), _params).ToArray();
_connection.Close();
@@ -625,29 +603,7 @@ namespace ZKLT.Hadoop
_command.AppendLine(@$"SELECT * FROM `{table.Key}`");
//执行条件
- StringBuilder _wherestr = new StringBuilder();
- _wherestr.Append("WHERE 1 = 1");
- if (where != null && where.Count > 0)
- {
- for (var i = 0; i < table.Columns.Length; i++)
- {
- var _column = table.Columns[i];
- if (where.ContainsKey(_column.Key!))
- {
- switch (where[_column.Key!])
- {
- case HDP_WhereType.LIKE:
- _wherestr.Append($@" AND `{_column.Key!}` {where[_column.Key!]} CONCAT('%',@{_column.Key!},'%')");
- break;
- default:
- _wherestr.Append($@" AND `{_column.Key!}` {where[_column.Key!]} @{_column.Key!}");
- break;
- }
- _params.Add(_column.Key!, row[_column.Key!]);
- }
- }
- _command.AppendLine(_wherestr.ToString());
- }
+ MergeWhere(table, where, row, _command, _params);
//执行排序
StringBuilder _orderstr = new StringBuilder();
@@ -719,29 +675,8 @@ namespace ZKLT.Hadoop
_command.AppendLine(@$"SELECT * FROM `{table.Key}`");
//执行条件
- StringBuilder _wherestr = new StringBuilder();
- _wherestr.Append("WHERE 1 = 1");
- if (where != null && where.Count > 0)
- {
- for (var i = 0; i < table.Columns.Length; i++)
- {
- var _column = table.Columns[i];
- if (where.ContainsKey(_column.Key!))
- {
- switch (where[_column.Key!])
- {
- case HDP_WhereType.LIKE:
- _wherestr.Append($@" AND `{_column.Key!}` {where[_column.Key!]} '%' + @{_column.Key!} + '%'");
- break;
- default:
- _wherestr.Append($@" AND `{_column.Key!}` {where[_column.Key!]} @{_column.Key!}");
- break;
- }
- _params.Add(_column.Key!, row[_column.Key!]);
- }
- }
- _command.AppendLine(_wherestr.ToString());
- }
+ MergeWhere(table, where, row, _command, _params);
+
//执行排序
StringBuilder _orderstr = new StringBuilder();
_orderstr.Append("ORDER BY ");