DDD - How can I avoid crossing common borders here?

We are working on a new project (rewriting an existing application), and I am having problems with the design of my model / repository.

Here is a (simplified) version of two key parts in our domain model:

alt text

As you can see, I have an abstract Post concept that may look like a review, discussion, photo, video, etc. Posts also have comments.

I also have the abstract concept of Location , which obviously refers to streets, cities, neighborhoods, etc.

Now, it naturally looked like two distinct aggregate roots.

So, I created two repositories, one of which is called PostRepository , and the other - LocationRepository .

All this worked fine, I can add / receive any type of message (or comment) and add / receive any type of location through one of these two repositories.

But now im in the "landing page" script for the City (for example).

On this page, I mainly need to show "all posts for this location."

? , () . , ( , DDD), , , , / .

?

? ?

( ), - (ASP.NET MVC) SQL Server 2008 Entity Framework 4.0.

- , .

Specification .

, BLL , Score >= 4:

var reviews = postRepository // GenericRepository<Post>
      .Find() // IQueryable<Post>
      .OfType<Review>() // IQueryable<Review>
      .Where(x => x.Score >= 4)
      .ToList(); // List<Review>

:

var reviews = postRepository
    .Find()
    .OfType<Review>()
    .Where( //lat long, or Locations FK )
    .ToList();

, , (LocationPost - ) FK Post .

, , - ?

+5
3

, ( ) . :

:

var p = new Post(latitude, longitude);
var locations = locationRepository.FindByCoordinates(latitude, longitude);
foreach (var l in locations)
{
    l.AssociatePost(p);
}
session.Save(p);

:

var associatedPosts = postRepository.FindByLocation(locationId);
foreach (var p in associatedPosts)
{
    Display(p);
}

. : ( ).

, .

+6

? , AR AR. ( AR AR)

, ? , . ? , - .

AR:

, , , AR , ID .

, , - .

+9

Say you used the Specification template, can you build a Post Specification using the Location object? Then you simply pass the specification to your mail repository and return the result.

0
source

All Articles