sharp architecture, FluentNHibernate, automapper, DTO, 1:m persistence question
- by csetzkorn
Let us say we have a class A which has a reference to another class B (1:m)
public class A
{
public virtual B B { get; set; }
}
I reflect this using FluentNHibernate within the sharp architecture and also manage to ‘initialise’ A and its B via a DTO and Automapper. The DTO contain A’s values and B (just B’s id value/A’s foreign key initialised).
I was hoping that I can persist A by ‘just’ using its 'out of the box repository' without requiring B’s repository using:
SaveOrUpdate(A);
(A has been mapped using AutoMapper and contains B with its Id initialised)
Was my assumption too naive?
Can I achieve this somehow (without ever requiring B’s repository)?
Or do I have to use A’s and B’s repository in, for example, the controller or some other service layer?
Thanks.
Best wishes,
Christian