diff --git a/Hadoop/ZKLT.Hadoop.Model/HDP_WhereType.cs b/Hadoop/ZKLT.Hadoop.Model/HDP_WhereType.cs index 481eca6..b39275b 100644 --- a/Hadoop/ZKLT.Hadoop.Model/HDP_WhereType.cs +++ b/Hadoop/ZKLT.Hadoop.Model/HDP_WhereType.cs @@ -23,5 +23,7 @@ namespace ZKLT.Hadoop.Model public const string LESSTHEN = "<="; public const string IN = "IN"; + + public const string BETWEEN = "BETWEEN"; } } diff --git a/Hadoop/ZKLT.Hadoop/TableService.cs b/Hadoop/ZKLT.Hadoop/TableService.cs index fee0a39..daf6ee9 100644 --- a/Hadoop/ZKLT.Hadoop/TableService.cs +++ b/Hadoop/ZKLT.Hadoop/TableService.cs @@ -10,6 +10,7 @@ using ZKLT.Hadoop.Interface; using ZKLT.Hadoop.Model; using MySqlX.XDevAPI.Relational; using Mysqlx.Crud; +using Newtonsoft.Json; namespace ZKLT.Hadoop { @@ -39,12 +40,30 @@ namespace ZKLT.Hadoop { case HDP_WhereType.LIKE: _wherestr.Append($@" AND `{_column.Key!}` {where[_column.Key!]} CONCAT('%',@{_column.Key!},'%')"); + param.Add(_column.Key!, row![_column.Key!]); + break; + case HDP_WhereType.BETWEEN: + if (row![_column.Key!] != null) { + var _betweendata = JsonConvert.DeserializeObject(JsonConvert.SerializeObject(row![_column.Key!])); + if (_betweendata != null) { + if (_betweendata[0] != null) + { + _wherestr.Append($@" AND `{_column.Key!}` >= @{_column.Key!}0"); + param.Add(_column.Key! + "0", _betweendata[0]); + } + if (_betweendata[1] != null) + { + _wherestr.Append($@" AND `{_column.Key!}` <= @{_column.Key!}1"); + param.Add(_column.Key! + "1", _betweendata[1]); + } + } + } break; default: _wherestr.Append($@" AND `{_column.Key!}` {where[_column.Key!]} @{_column.Key!}"); + param.Add(_column.Key!, row![_column.Key!]); break; } - param.Add(_column.Key!, row![_column.Key!]); } } command.AppendLine(_wherestr.ToString());