Code Monkey home page Code Monkey logo

Comments (4)

alirezanet avatar alirezanet commented on August 16, 2024

Hi @sebdm,

I think this is not a bug, but rather a design choice; in this case, your parenthesis is redundant.

when you don't use any parenthesis by default you get something like the below query:

var query = list.Where(q => q.subList.Any(w=> w.field == value)  && q.subList.Any(w=> w.field2 == value2)  ); 

but sometimes we want both conditions inside the Any function. like:

var query = list.Where(q => q.subList.Any(w=> w.field == value && w.field2 == value2) ); 

So we can use a pair of parenthesis to group two conditions in one expression. (field=value1,field2=value2).

if you want to have separate expressions with parenthesis you have to add another set of parenthesis around each part. (field=value1),(field2=value2)

PS. I didn't test this fully yet,
Let me know if you solved the problem or not.

from gridify.

sebdm avatar sebdm commented on August 16, 2024

First of all, thanks for your quick response (and for a great library :))

These do what I want:
field=value1,field=value2
(field=value1),(field=value2)

These don't:
(field=value1,field=value2)
((field=value1),(field=value2))

So basically this is limiting me a bit when it comes to some edge cases.

Maybe it would be more clear with a different operator for "IN", e g:
field IN value1,value2

Or perhaps even cleaner if I didn't need to map the nested field to the top-level at all, e g:
child.field IN value1,value2

Or for multiple where's on the same IN:
child.field as F IN f>lower,f<upper

These are just ideas off the top of my head. I realize that implementing this in expression trees is far from trivial (not my expertise anyway :/)

I can, for now, in this particular case, just remove the parentheses altogether, but I can see other potential cases when that wouldn't be a viable solution due to this ambiguity.

from gridify.

alirezanet avatar alirezanet commented on August 16, 2024

These are just ideas off the top of my head. I realize that implementing this in expression trees is far from trivial (not my expertise anyway :/)
I can, for now, in this particular case, just remove the parentheses altogether, but I can see other potential cases when that wouldn't be a viable solution due to this ambiguity.

To make the edge cases clear it would be great if you can provide a LINQ version of the query that is not supported by gridify,
because after all, I'm trying to convert a small query language to a LINQ expression, So far I managed to pass the tests of all possible scenarios that came to my mind but because it's the complexity I won't be surprised if still there are other edge cases that I missed.

Also, I should admit that parenthesis in sublists behaves differently, probably I should've documented it better.

In the end, If you found any edge case that is not supported yet, I'll be happy to add it to the library.

Thanks

from gridify.

alirezanet avatar alirezanet commented on August 16, 2024

Maybe it would be more clear with a different operator for "IN", e g:
field IN value1,value2

I forget this one. This is a good idea to somehow support parenthesis only for values ( filed=(value1,value2) ) but I haven't done that because this way you have to deal with a lot of escape characters.

although with the custom operators feature, you can implement your own IN if you need it.

from gridify.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.