增加between

main
潘建东 6 months ago
parent d9df8b5111
commit f0001de997

@ -23,5 +23,7 @@ namespace ZKLT.Hadoop.Model
public const string LESSTHEN = "<="; public const string LESSTHEN = "<=";
public const string IN = "IN"; public const string IN = "IN";
public const string BETWEEN = "BETWEEN";
} }
} }

@ -10,6 +10,7 @@ using ZKLT.Hadoop.Interface;
using ZKLT.Hadoop.Model; using ZKLT.Hadoop.Model;
using MySqlX.XDevAPI.Relational; using MySqlX.XDevAPI.Relational;
using Mysqlx.Crud; using Mysqlx.Crud;
using Newtonsoft.Json;
namespace ZKLT.Hadoop namespace ZKLT.Hadoop
{ {
@ -39,12 +40,30 @@ namespace ZKLT.Hadoop
{ {
case HDP_WhereType.LIKE: case HDP_WhereType.LIKE:
_wherestr.Append($@" AND `{_column.Key!}` {where[_column.Key!]} CONCAT('%',@{_column.Key!},'%')"); _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<object[]>(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; break;
default: default:
_wherestr.Append($@" AND `{_column.Key!}` {where[_column.Key!]} @{_column.Key!}"); _wherestr.Append($@" AND `{_column.Key!}` {where[_column.Key!]} @{_column.Key!}");
param.Add(_column.Key!, row![_column.Key!]);
break; break;
} }
param.Add(_column.Key!, row![_column.Key!]);
} }
} }
command.AppendLine(_wherestr.ToString()); command.AppendLine(_wherestr.ToString());

Loading…
Cancel
Save