Giter Site home page Giter Site logo

Comments (5)

Amin-ir avatar Amin-ir commented on June 11, 2024 1

Fantastic! you see, I feel the queries so much more readable once written using SqlKata chaining methods, and then only converted to raw SQL to be fed into an ORM.
TY!

from querybuilder.

ahmad-moussawi avatar ahmad-moussawi commented on June 11, 2024 1

You're right. Is there any other way to compile query?

If you are not the SqlKata.Execution package, you should use the SqlResult class to get the SQL string with the parameters bindings.

See https://github.com/sqlkata/querybuilder/blob/master/SqlKata.Execution/QueryFactory.cs#L77 as an example

from querybuilder.

Revazashvili avatar Revazashvili commented on June 11, 2024

Yes, you can. package contains compilers for every database it supports, under SqlKata.Compilers namespace.

you can use Compile method to get SqlResult which contains Sql and RawSql properties. if you want to get Sql parsed with actually passed parameters call ToString() method on SqlResult.

Example with postgres;

var query = new Query();
var compiler = new PostgresCompiler();
var sqlResult = compiler.Compile(query);
var sql = sqlResult.ToString();

from querybuilder.

ahmad-moussawi avatar ahmad-moussawi commented on June 11, 2024

It is worth noting that the ToString() method is meant only for debugging purposes and not for executing queries.
Check https://sqlkata.com/docs#compile-only-example

from querybuilder.

Revazashvili avatar Revazashvili commented on June 11, 2024

You're right. Is there any other way to compile query?

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.