Skip to content

Instantly share code, notes, and snippets.

View mattjohnsonpint's full-sized avatar

Matt Johnson-Pint mattjohnsonpint

View GitHub Profile
@mattjohnsonpint
mattjohnsonpint / Tests.cs
Created October 9, 2012 18:50
RavenDB Bug
using System.Linq;
using Raven.Client.Embedded;
using Raven.Client.Indexes;
using Xunit;
namespace RavenTests
{
public class Tests
{
[Fact]
@mattjohnsonpint
mattjohnsonpint / Tests.cs
Created October 10, 2012 19:39
RavenDB Bug with skipping empty arrays in reduce projection
using System.Linq;
using Raven.Client.Embedded;
using Raven.Client.Indexes;
using Xunit;
namespace RavenTests
{
public class Tests
{
[Fact]
@mattjohnsonpint
mattjohnsonpint / Tests.cs
Created October 19, 2012 00:13
RavenDB issue with getting versioned documents from a tenant db
using System;
using System.Linq;
using Raven.Abstractions.Data;
using Raven.Client;
using Raven.Client.Bundles.Versioning;
using Raven.Client.Document;
using Raven.Client.Extensions;
using Xunit;
namespace RavenTests
@mattjohnsonpint
mattjohnsonpint / Tests.cs
Created October 26, 2012 03:02
RavenDB Bug getting DateTimeOffset value from metadata
using System;
using Raven.Client.Embedded;
using Raven.Json.Linq;
using Xunit;
namespace RavenTests
{
public class Tests
{
[Fact]
@mattjohnsonpint
mattjohnsonpint / Example.cs
Created October 31, 2012 23:42
Showing how to do map/reduce by local date with conversion
public class Appointment
{
public string Id { get; set; }
public DateTimeOffset AppointmentTime { get; set; }
public string TimeZone { get; set; }
}
public class Appointments_CountsByDate : AbstractIndexCreationTask<Appointment, Appointments_CountsByDate.Result>
{
public class Result
@mattjohnsonpint
mattjohnsonpint / Tests.cs
Created November 4, 2012 23:17
Another RavenDB issue with DateTimeOffset in metadata
using System;
using Raven.Client.Embedded;
using Xunit;
namespace RavenTests
{
public class Tests
{
[Fact]
public void Can_Save_And_Load_DateTimeOffset_From_Metadata()
@mattjohnsonpint
mattjohnsonpint / WaitForIndexToBecomeNonStale.cs
Created November 11, 2012 16:31
Waiting for an index from within a trigger...
internal static void WaitForIndexToBecomeNonStale(this DocumentDatabase database, string name, DateTime? cutOff, Guid? cutoffEtag)
{
var task = Task.Factory.StartNew(() =>
{
while (true)
{
var stale = true;
database.TransactionalStorage.Batch(x =>
{
stale = x.Staleness.IsIndexStale(name, cutOff, cutoffEtag);
@mattjohnsonpint
mattjohnsonpint / RavenExtensions.cs
Created October 2, 2012 21:22
RavenDB Extension Method to generate an ID without storing the document
public static string GenerateIdFor<T>(this IDocumentSession session)
{
// We need the advanced session in order to ensure that the keys are generated in the correct database.
// session.Advanced.DocumentStore.DatabaseCommands is not sufficient.
var advancedSession = session.Advanced as DocumentSession;
if (advancedSession == null)
throw new InvalidOperationException();
// An entity instance is required to generate a key, but we only have a type.
// In our case, the entities don't have public constructors so we must use reflection.
@mattjohnsonpint
mattjohnsonpint / Tests.cs
Created November 21, 2012 03:09
Tests showing issue with .Any
using System.Collections.Generic;
using System.Linq;
using Raven.Client.Embedded;
using Xunit;
namespace RavenTests
{
public class Tests
{
[Fact]
@mattjohnsonpint
mattjohnsonpint / Tests.cs
Created November 24, 2012 01:04
Raven Studio Caching
public class Ball
{
public string Id { get; set; }
public string Color { get; set; }
}
[Fact]
public void Test()
{
var documentStore = new EmbeddableDocumentStore { RunInMemory = true };