Eric Polerecky bio photo

Director, Professional Services @RightBrain_Net - 50% engineer, 50% entrepreneur. Former: CTO @Wantify, @agilesoftware, @grasshopper

Eric Polerecky

Email Twitter LinkedIn Github Stackoverflow


Xamarin (expired)


Microservices? Real World FRP Xamarin Forms Case Study

All Posts

All Posts

I’m really digging the DDD Aggregate root design pattern and thought it would be good to create an example of using EF to pull a root from the persistence layer (database).

My database:


In my little database prjects have releases and stories. releases have sprints and stories and stories have tasks. My root is a project.


My model (EF)


A method for pulling the root:

Its important to note that child objects must be included in the query. ex: Include(“Stories.Tasks”) will get the tasks.

All the projects

Dim _entities As Entities.EntityFrameworkEntities = New Entities.EntityFrameworkEntitiesReturn

**A specific project. **

Function GetById(ByVal Id As Integer) As Entities.Projects       
Return _entities.Projects().Include(“Releases”).Include(“Stories”).Include(“Stories.Tasks”).Where(Function(p) p.ProjectId = Id).FirstOrDefault
End Function

.csharpcode, .csharpcode pre
font-size: small;
color: black;
font-family: consolas, “Courier New”, courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
background-color: #f4f4f4;
width: 100%;
margin: 0em;
.csharpcode .lnum { color: #606060; }