Instead of executing sql queries with plain query Strings I would like to use some kind of builder pattern to be able to execute type save sql queries in C#. In other words I am looking for an SQL wrapper API.

For Java there is JOOQ: https://www.jooq.org/doc/3.9/manual/getting-started/tutorials/jooq-in-7-steps/

It generates some code from a database (e.g. static classes, enumerations) and that code can then be referenced to create type save queries, e.g.

 Result<Record> result = create.select().from(AUTHOR).fetch();

 for (Record r : result) {
      Integer id = r.getValue(AUTHOR.ID);
      String firstName = r.getValue(AUTHOR.FIRST_NAME);
      String lastName = r.getValue(AUTHOR.LAST_NAME);

      System.out.println("ID: " + id + " first name: " + firstName + " last name: " + lastName);

Is there a similar library for C#?

  • 1
    In C#, this is usually done using LINQ. Is that acceptable for you?
    – svick
    Mar 15 '17 at 14:56
  • If you write this as answer I'll accept it. I am still struggling on how to generate the "LINQ to SQL classes" item for SqLite but that's another topic. The general idea is shown here for a microsoft database: youtube.com/watch?v=8K_QKIX0wcc
    – Stefan
    Mar 21 '17 at 18:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.