Skip to content

Commit d435808

Browse files
committed
Handling more conditions operators #1054
1 parent 4125e2d commit d435808

File tree

1 file changed

+33
-5
lines changed

1 file changed

+33
-5
lines changed

FetchXmlBuilder/Converters/SQLQueryGenerator.cs

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ private static string GetCondition(string entityname, string entityalias, FetchC
215215
{
216216
throw new Exception($"No metadata for attribute: {entityname}.{condition.attribute}");
217217
}
218+
var value = condition.value;
218219
switch (condition.@operator)
219220
{
220221
case @operator.eq:
@@ -260,9 +261,36 @@ private static string GetCondition(string entityname, string entityalias, FetchC
260261
case @operator.notlike:
261262
result.Append(" NOT LIKE ");
262263
break;
263-
//case @operator.beginswith:
264-
// result.Append(" LIKE \"{0}%\"");
265-
// break;
264+
265+
case @operator.beginswith:
266+
result.Append(" LIKE ");
267+
value = $"{value}%";
268+
break;
269+
270+
case @operator.notbeginwith:
271+
result.Append(" NOT LIKE ");
272+
value = $"{value}%";
273+
break;
274+
275+
case @operator.endswith:
276+
result.Append(" LIKE ");
277+
value = $"%{value}";
278+
break;
279+
280+
case @operator.notendwith:
281+
result.Append(" NOT LIKE ");
282+
value = $"%{value}";
283+
break;
284+
285+
case @operator.containvalues:
286+
result.Append(" LIKE ");
287+
value = $"%{value}%";
288+
break;
289+
290+
case @operator.notcontainvalues:
291+
result.Append(" NOT LIKE ");
292+
value = $"%{value}%";
293+
break;
266294
//case @operator.@in:
267295
// result.Append(" IN ");
268296
// break;
@@ -286,11 +314,11 @@ private static string GetCondition(string entityname, string entityalias, FetchC
286314
case AttributeTypeCode.State:
287315
case AttributeTypeCode.Status:
288316
case AttributeTypeCode.Picklist:
289-
result.Append(condition.value);
317+
result.Append(value);
290318
break;
291319

292320
default:
293-
result.Append($"'{condition.value}'");
321+
result.Append($"'{value}'");
294322
break;
295323
}
296324
}

0 commit comments

Comments
 (0)