Git Product home page Git Product logo

linqpad-postgresql-driver's Introduction

LINQPad PostgreSQL Driver

Build status

This is a driver for LINQPad to add support for PostgreSQL databases. This driver uses LINQ to DB to execute the LINQ queries and Npgsql for the database access. In addition Dapper is used for a more convenient database access during the model creation.

This driver has been tested with PostgreSQL 9.4.4 but should work with all versions supported by LINQ to DB v1.0.7.4 and Npgsql v3.0.7. It can be used with LINQPad versions 4 and 5.

Installation

  1. Download the .lpx file of the latest release from the releases tab (e.g. LINQPad.PostgreSQL.Driver.0.1.2.lpx).
  2. Run LINQPad and click Add connection.
  3. Click View more drivers.
  4. Click Browse and select the .lpx file. The driver has now been installed.
  5. The driver (PostgreSQL (LINQ to DB)) should now show up in the Add connection dialog.

Setting up a connection

  1. Click Add connection, select the driver and click Next.
  2. Provide the connection info by either specifying the server (e.g. localhost:5432) and database (with optional username and password) or by specifying a Npgsql connection string manually. If you do not specify a port explicitly the default port 5432 is used.
  3. Create the connection by clicking the Save button.

Modifying data

Unfortunately, editing data directly in the results grid is not supported for third-party drivers. You can, however, use the LINQ to DB DataConnection to modify your data. The DataConnection can be accessed using the this keyword in your query. In the following some samples to insert, update and delete records are provided. You can get more detailed information on the LINQ to DB website.

Insert

If you want to provide an ID yourself:

var user = new User();
user.Id = 42;
user.Name = "John Doe";
user.Emailaddress = "[email protected]";

this.Insert(user);

If the ID is generated by the database:

var user = new User();
user.Name = "John Doe";
user.Emailaddress = "[email protected]";

var userId = this.InsertWithIdentity(user);

Update

If you have an instance of the object you want to update:

var user = Users.Single(u => u.Id == 42);
user.Emailaddress = "[email protected]";

this.Update(user);

If you want to update all records matching certain criteria:

Users.Where(u => u.Id == 42)
	 .Set(u => u.Emailaddress, "[email protected]")
	 .Update();

Delete

If you have an instance of the object you want to delete:

var user = Users.Single(u => u.Id == 42);
this.Delete(user);

If you want to delete all records matching certain criteria:

Users.Delete(u => u.Id == 42);

linqpad-postgresql-driver's People

Contributors

fknx avatar henrik-m avatar notdev avatar teejay-87 avatar

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.