Git Product home page Git Product logo

Comments (4)

ahmad-moussawi avatar ahmad-moussawi commented on September 28, 2024

Something like:

class Group {
 public List<Condition> Conditions {get; set;}
}

class Condition {
 public string Field {get; set;}
 public string Operator {get; set;} 
 public object Value {get; set;}  
}

var query = new Query("Countries");

foreach(Group group in groups) 
{
   query.Where(q => {
      foreach(Condition c in group.Conditions)
      {
         q.OrWhere(c.Field, c.Operator, c.Value);
      }
      return q;
   });
}

from querybuilder.

ahmad-moussawi avatar ahmad-moussawi commented on September 28, 2024

I will close this for now, feel free to reopen if something is not clear

from querybuilder.

rs199483 avatar rs199483 commented on September 28, 2024

@ahmad-moussawi I need to create groups like you have above but your code will not compile.
.NetFiddle here

Compilation error (line 37, col 18): Not all code paths return a value in lambda expression of type 'System.Func<SqlKata.Query,SqlKata.Query>'
Compilation error (line 37, col 18): Cannot convert lambda expression to type 'object' because it is not a delegate type

Expected output:

SELECT * FROM [Countries] WHERE ([Group1Field1] = @p0 OR [Group1Field2] > @p1 OR [Group1Field3] < @p2 OR [Group1Field4] = @p3) OR( [Group2Field1] = @p4 OR [Group2Field2] >= @p5 OR [Group2Field3] <= @p6)

from querybuilder.

ahmad-moussawi avatar ahmad-moussawi commented on September 28, 2024

@rs199483 thanks for the update, yes this is outdated now, I will update the original answer

from querybuilder.

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.