Created
April 2, 2013 09:06
-
-
Save e-tobi/5290942 to your computer and use it in GitHub Desktop.
RavenDB "caching" not existing documents
This file contains hidden or 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.Linq; | |
using Raven.Client.Embedded; | |
using Raven.Database.Extensions; | |
namespace etobi.RavenDB2Test01 | |
{ | |
public class Program | |
{ | |
private static EmbeddableDocumentStore _documentStore; | |
static void Main(string[] args) | |
{ | |
IOExtensions.DeleteDirectory("Data"); | |
using (_documentStore = new EmbeddableDocumentStore | |
{ | |
Configuration = | |
{ | |
DataDirectory = "Data", | |
}, | |
}) | |
{ | |
_documentStore.Initialize(); | |
using (var session1 = _documentStore.OpenSession()) | |
{ | |
var foo = session1.Load<Foo>("foos/1"); | |
using (var session2 = _documentStore.OpenSession()) | |
{ | |
session2.Store(new Foo { Id = "foos/1", Name = "Something"}); | |
session2.SaveChanges(); | |
} | |
foo = session1.Load<Foo>("foos/1"); | |
// foo is still null here | |
foo = session1.Query<Foo>().FirstOrDefault(); | |
// This actually returns foo | |
} | |
} | |
} | |
} | |
public class Foo | |
{ | |
public string Id { get; set; } | |
public string Name { get; set; } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment