@@ -22,6 +22,10 @@ type ObjectListFilter =
2222 | Contains of FieldFilter < System.IComparable >
2323 | OfTypes of Type list
2424 | FilterField of FieldFilter < ObjectListFilter >
25+ | EqualsCI of FieldFilter < string >
26+ | StartsWithCI of FieldFilter < string >
27+ | EndsWithCI of FieldFilter < string >
28+ | ContainsCI of FieldFilter < string >
2529
2630open System.Linq
2731open System.Linq .Expressions
@@ -124,9 +128,21 @@ module ObjectListFilter =
124128 /// Creates a new ObjectListFilter representing a field sub comparison.
125129 let ( - -> ) fname filter = FilterField { FieldName = fname ; Value = filter }
126130
127- /// Creates a new ObjectListFilter representing a NOT opreation for the existing one.
131+ /// Creates a new ObjectListFilter representing a NOT operation for the existing one.
128132 let ( !!! ) filter = Not filter
129133
134+ /// Creates a new ObjectListFilter representing a case - insensitive EQUALS operation on a string value.
135+ let ( === ~ ) fname value = EqualsCI { FieldName = fname ; Value = value }
136+
137+ /// Creates a new ObjectListFilter representing a case - insensitive STARTS WITH operation on a string value.
138+ let ( =@@ ~ ) fname value = StartsWithCI { FieldName = fname ; Value = value }
139+
140+ /// Creates a new ObjectListFilter representing a case - insensitive ENDS WITH operation on a string value.
141+ let ( @@= ~ ) fname value = EndsWithCI { FieldName = fname ; Value = value }
142+
143+ /// Creates a new ObjectListFilter representing a case - insensitive CONTAINS operation on a string value.
144+ let ( @=@ ~ ) fname value = ContainsCI { FieldName = fname ; Value = value }
145+
130146 let private genericWhereMethod =
131147 typeof < Queryable > .GetMethods ()
132148 |> Seq.where ( fun m -> m.Name = " Where" )
@@ -147,6 +163,12 @@ module ObjectListFilter =
147163 let private StringStartsWithMethod = stringType.GetMethod ( " StartsWith" , [| stringType |])
148164 let private StringEndsWithMethod = stringType.GetMethod ( " EndsWith" , [| stringType |])
149165 let private StringContainsMethod = stringType.GetMethod ( " Contains" , [| stringType |])
166+ let private stringComparisonType = typeof< StringComparison>
167+ let private StringEqualsCIMethod = stringType.GetMethod ( " Equals" , [| stringType; stringComparisonType |])
168+ let private StringStartsWithCIMethod = stringType.GetMethod ( " StartsWith" , [| stringType; stringComparisonType |])
169+ let private StringEndsWithCIMethod = stringType.GetMethod ( " EndsWith" , [| stringType; stringComparisonType |])
170+ let private StringContainsCIMethod = stringType.GetMethod ( " Contains" , [| stringType; stringComparisonType |])
171+ let private OrdinalIgnoreCase = Expression.Constant ( StringComparison.OrdinalIgnoreCase)
150172 let private unwrapOptionMethod =
151173 FSharp.Data.GraphQL.Helpers.moduleType.GetMethod ( nameof Helpers.unwrap)
152174
@@ -329,6 +351,18 @@ module ObjectListFilter =
329351 | FilterField f ->
330352 let paramExpr = Expression.PropertyOrField ( param, f.FieldName)
331353 buildFilterExpr isEnumerableQuery ( SourceExpression paramExpr) buildTypeDiscriminatorCheck f.Value
354+ | EqualsCI f ->
355+ let ``member`` = Expression.PropertyOrField ( param, f.FieldName)
356+ Expression.Call ( normalizeStringMemberExpr `` member `` , StringEqualsCIMethod, Expression.Constant f.Value, OrdinalIgnoreCase)
357+ | StartsWithCI f ->
358+ let ``member`` = Expression.PropertyOrField ( param, f.FieldName)
359+ Expression.Call ( normalizeStringMemberExpr `` member `` , StringStartsWithCIMethod, Expression.Constant f.Value, OrdinalIgnoreCase)
360+ | EndsWithCI f ->
361+ let ``member`` = Expression.PropertyOrField ( param, f.FieldName)
362+ Expression.Call ( normalizeStringMemberExpr `` member `` , StringEndsWithCIMethod, Expression.Constant f.Value, OrdinalIgnoreCase)
363+ | ContainsCI f ->
364+ let ``member`` = Expression.PropertyOrField ( param, f.FieldName)
365+ Expression.Call ( normalizeStringMemberExpr `` member `` , StringContainsCIMethod, Expression.Constant f.Value, OrdinalIgnoreCase)
332366
333367 type private CompareDiscriminatorExpressionVisitor < 'T , 'D >
334368 ( compareDiscriminator : CompareDiscriminatorExpression< 'T, 'D>, param : SourceExpression, value : obj) =
0 commit comments