Skip to content

Instantly share code, notes, and snippets.

@jeffrymorris
Last active August 2, 2016 00:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeffrymorris/c3bf85d73a1e7dfcc5f25f4e581d689a to your computer and use it in GitHub Desktop.
Save jeffrymorris/c3bf85d73a1e7dfcc5f25f4e581d689a to your computer and use it in GitHub Desktop.
Linq2Couchbase Quick Start
using System;
using System.Collections.Generic;
using System.Linq;
using Couchbase;
using Couchbase.Configuration.Client;
using Couchbase.Linq;
using Newtonsoft.Json;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
ClusterHelper.Initialize(new ClientConfiguration
{
Servers = new List<Uri> {new Uri("http://localhost:8091/")}
});
var context = new BucketContext(ClusterHelper.GetBucket("travel-sample"));
var query = (from a in context.Query<AirLine>()
select a).
Take(10);
query.ToList().ForEach(Console.WriteLine);
ClusterHelper.Close();
}
public class AirLine
{
public string Id { get; set; }
public string Type { get; set; }
public string Name { get; set; }
public string Iata { get; set; }
public string Icao { get; set; }
public string Callsign { get; set; }
public string Country { get; set; }
public override string ToString()
{
return JsonConvert.SerializeObject(this);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment