Skip to content

Instantly share code, notes, and snippets.

@jasondentler
Created August 6, 2013 19:54
Show Gist options
  • Save jasondentler/6168007 to your computer and use it in GitHub Desktop.
Save jasondentler/6168007 to your computer and use it in GitHub Desktop.
public class EditMasterQuery
{
private readonly IDocumentSession _session;
public EditMasterQuery(IDocumentSession session)
{
_session = session;
}
public MasterWithSubdocs Execute(string masterId)
{
var master = _session.Load(masterId);
if (master == null)
return null;
var scope = master.Scope;
var subdocs = _session.Query<SubDocuments>()
.Where(/* subdoc matches scope */)
.ToList();
return new MasterWithSubdocs(Master = master, SubDocs = subdocs);
}
}
public class AssembleMasterQuery
{
private readonly IDocumentSession _session;
public AssembleMasterQuery(IDocumentSession session)
{
_session = session;
}
public MasterWithSubdocs Execute(string masterId)
{
var master = _session.Include<Master>(m => m.SubDocIds).Load(masterId);
var subdocs = _session.Load<SubDoc>(master.SubDocIds);
return new MasterWithSubdocs(Master = master, SubDocs = subdocs);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment