Created
August 6, 2013 19:54
-
-
Save jasondentler/6168007 to your computer and use it in GitHub Desktop.
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
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