ninjanye / SearchExtensions

Library of IQueryable extension methods to perform searching

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

OR with different criteria

sunflowerlab opened this issue · 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

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

@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.

Any news on this issue?

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 !