SearchExtensions icon indicating copy to clipboard operation
SearchExtensions copied to clipboard

OR with different criteria

Open sunflowerlab opened this issue 9 years ago • 4 comments

Hi, I have just started using your extension and let me tell you. Its working perfectly. You saved lots of my time. I have unique requirement and see if this can be achieve using your extension.

I want to do OR on same property but with different options like "StartsWith", "EndsWtih" etc.

for Example.

var result = queryableData.Search(x => x.Property1) .StartsWith("abc") .Containing("mno");

On above code get all property1 where its either startwith "abc" or contains "mno".

I think current implementation does AND. Is there any way i can achieve this?

Thanks

sunflowerlab avatar Dec 06 '15 17:12 sunflowerlab

Hi @sunflowerlab

Really sorry it has taken me this long to reply, I completely missed this issue arrive. I will look into this and see what is possible as currently, as you rightly say, the code sample above will produce and AND join.

Speak soon

ninjanye avatar Dec 18 '15 08:12 ninjanye

@sunflowerlab, As a workaround, you could implement something like:

var startsWith = TestModels.Search(p => p.StringOne)
                           .StartsWith("abc");
var contains = TestModels.Search(p => p.StringOne)
                         .Containing("xyz");

It does mean performing 2 queries which I know is not ideal, but i might get you over this hump.

I will look at how this could be properly supported in SearchExtensions.

ninjanye avatar Dec 18 '15 08:12 ninjanye

Any news on this issue?

wouter-b avatar Feb 11 '22 14:02 wouter-b

I came here looking for similar, data = data.Search(x => x.StringProperty).Containing(list.Where(x => x.ToIntDef(0) == 0).ToArray()); data = data.Search(x => x.IntegerProperty).EqualTo(276, 1001); I would like to OR that !

eLPe21 avatar Mar 01 '22 15:03 eLPe21