Skip to content

Instantly share code, notes, and snippets.

@BillKeenan
Created July 30, 2012 13:15
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 BillKeenan/3206786 to your computer and use it in GitHub Desktop.
Save BillKeenan/3206786 to your computer and use it in GitHub Desktop.
public Share GetShare(string shareId)
{
try
{
using (var session = DocumentStore.OpenSession())
{
var share = (from m in session.Query<Share>() where m.Id == shareId select m).FirstOrDefault();
//session.Query<Share>(shareId).FirstOrDefault(x => x.Id == shareId) ??
// session.Query<Share>().Where(x => x.Id == shareId).Customize(
// x => x.WaitForNonStaleResults(TimeSpan.FromSeconds(5))).FirstOrDefault();
if (share == null)
{
_loggerService.Info("waiting for non-stale:" + shareId);
share = (from m in session.Query<Share>() where m.Id == shareId select m).Customize(x=>x.WaitForNonStaleResults()).FirstOrDefault();
}
_loggerService.Info(String.Format("{0} share found?",(share!=null?share.Id:"nope")));
return share;
}
}catch (Exception e)
{
_loggerService.Fatal(e);
return null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment