Last active
August 2, 2016 00:46
-
-
Save jeffrymorris/c3bf85d73a1e7dfcc5f25f4e581d689a to your computer and use it in GitHub Desktop.
Linq2Couchbase Quick Start
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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