Skip to content

Instantly share code, notes, and snippets.

@PureKrome
Forked from ronnieoverby/gist:2372753
Created April 13, 2012 01:52
Show Gist options
  • Save PureKrome/2372797 to your computer and use it in GitHub Desktop.
Save PureKrome/2372797 to your computer and use it in GitHub Desktop.
namespace RavenLinqpadDriver
{
public class RavenContext : IDocumentSession
{
private IDocumentStore _docStore;
private IDocumentSession _session;
internal TextWriter LogWriter { get; set; }
public RavenContext(RavenConnectionInfo connInfo)
{
if (connInfo == null)
throw new ArgumentNullException("conn", "conn is null.");
InitDocStore(connInfo);
SetupLogWriting();
// Don't do this....
//_session = _docStore.OpenSession();
}
// New Lazy Loaded session.
private IDocumentSession Session
{
get { return _session ?? (_session = _docStore.OpenSession()); }
}
// The queries...
public IRavenQueryable<T> Query<T, TIndexCreator>() where TIndexCreator : AbstractIndexCreationTask, new()
{
return Session.Query<T, TIndexCreator>();
}
public IRavenQueryable<T> Query<T>()
{
return Session.Query<T>();
}
public IRavenQueryable<T> Query<T>(string indexName)
{
return Session.Query<T>(indexName);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment