Skip to content
master
Go to file
Code

Latest commit

Motivation
----------
Allow serialization converters to be registered for each cluster instead
of in a global static scope.

Modifications
-------------
Add a hidden DefaultSerializationConverterProvider as internal, and add
a method to inject an alternative via CouchbaseLinqConfiguration.

Also add the IJsonNetSerializationConverterRegistry as a setting to
CouchbaseLinqConfiguration to provide a method to easily inject custom
converters without replacing DefaultSerializationConverterProvider.

Update SerializationExpressionTreeProcessor to get the
ISerizationConverterProvider from DI.

Results
-------
Serialization converters are more easily customizable.

Closes #324
ef2d87b

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
Src
 
 
 
 
 
 
 
 
 
 

README.md

Linq2Couchbase

Join the chat at https://gitter.im/couchbaselabs/Linq2Couchbase .NET Core

The official Language Integrated Query (LINQ) provider for querying Couchbase Server with N1QL using the Couchbase .NET SDK. The goal of Linq2Couchbase is to create a lightweight ORM/ODM for querying Couchbase Buckets using LINQ as the lingua-franca between your application and Couchbase Server using N1QL, a SQL-like query language for JSON documents. It also provides a write API for performing CRUD operations on JSON documents.

While not an officially supported Couchbase project, this repo is actively maintained and monitored. If you happen to find a bug or have any questions, please either create an issue or make a post on forums.couchbase.com. Additionally, we actively accept contributions!

:info: This documentation is for Linq2Couchbase 2.x, compatible with Couchbase SDK 3.x. For documentation on Linq2Couchbase 1.x compatible with Couchbase SDK 2.x, see the release14 branch.

Getting started

The Linq2Couchbase project has the following dependencies:

  • Couchbase Server 4.0 or greater with the query service enabled on at least one node
  • Couchbase .NET SDK 3.0.3 or greater

Installing Couchbase Server

For a single instance of Couchbase Server running on localhost, you can download Couchbase Server here (make sure it's 4.0 or later). If you would like to create a cluster, the easiest way is by using the Vagrant scripts for provisioning clusters. Additionally, you can use Docker scripts. Follow the directions on each respective link for installation information.

Installing the package using NuGet

Once you have a Couchbase Server instance or cluster setup, open Visual Studio 2019 or greater or MonoDevelop and create a .NET or .NET Core application. Open the NuGet Package Manager and search for "Couchbase Linq" or type the following into the Package Manager console:

Install-Package Linq2Couchbase

Quick Start

This Quick Start assumes that you have already installed the travel-sample bucket, which is available and built-in to Couchbase Server.

Query the 'travel-sample' bucket and return 10 airlines in any order:

static async void Main() {
    var cluster = await Cluster.ConnectAsync("couchbase://localhost", options => {
        options.UserName = "Administrator";
        options.Password = "password";

        options.AddLinq();
    });

    // Wait until the cluster is bootstrapped
    await cluster.WaitUntilReadyAsync(TimeSpan.FromSeconds(10));

    var context = new BucketContext(await cluster.BucketAsync("travel-sample"));
    var query = (from a in context.Query<AirLine>()
                where a.Country == "United Kingdom"
                select a)
                .Take(10);

    await foreach (var airline in query.ToAsyncEnumerable())
    {
        Console.WriteLine(airline.Name);
    }
}

Upon running this query, you should expect console output similar to:

{"Id":"10642","Type":"airline","Name":"Jc royal.britannica","Iata":null,"Icao":"JRB","Callsign":null,"Country":"United Kingdom"}
{"Id":"112","Type":"airline","Name":"Astraeus","Iata":"5W","Icao":"AEU","Callsign":"FLYSTAR","Country":"United Kingdom"}
...
{"Id":"16881","Type":"airline","Name":"Air Cudlua","Iata":null,"Icao":"CUD","Callsign":"Cudlua","Country":"United Kingdom"}

Full code example, including AirLine class definition.

Developer Guide

Building From Source

Linq2Couchbase uses the NuGet package manager for handling dependencies. To build from the source, simply clone the GitHub repository and build in Visual Studio. The NuGet package manager should download all required dependencies.

Project management

In the Jira project for Linq2Couchbase, you can file bugs, propose features or get an idea for the roadmap there. There is also a list of supported and proposed N1QL features for Linq2Couchbase.

Contributors

Linq2Couchbase is an open source project and community contributions are welcome whether they be pull-requests, feedback or filing bug tickets or feature requests. We appreciate any contribution no matter how big or small! If you do decide to contribute, please browse the Jira project and ensure that that feature or issue hasn't already been documented. If you want to work on a feature, bug or whatever please create or select a ticket and set the status to "in-progress".

About

A Language Integrated Query (LINQ) provider for the Couchbase .NET SDK

Resources

License

Packages

No packages published

Languages

You can’t perform that action at this time.