Hi,
Please consider the domain model shown below (simplified for brevity - no ids etc.) A Customer
can comment on a Product
only once. Lets assume (for reasons I don't want to get into here) that the Customer
class cannot have a collection of Review
s that it owns. The Product
is the main Aggregate root here.
Often in this situation, when retrieving the Product
, it will only be in the context of a particular Customer
. In other words I will only be interested in the members of the Reviews
collection that belong to that particular Customer
.
So, it there a way, when retrieving the Product
object, of restricting the population of the collection to the review that relates to the Customer
I supply? How would this be implemented in NHibernate? Is this at all consistent with NHibernate best practices (and to a lesser degree DDD)?
public class Product
{
public virtual string Name { get; set; }
public virtual ISet<Review> Reviews{ get; set; }
public Product()
{
Reviews= new HashedSet<Review>();
}
}
public class Review
{
public virtual string ReviewText { get; set; }
public virtual Customer Reviewer { get; set; }
}
public class Customer
{
public virtual string Name { get; set; }
}
Thanks