I've got a simple domain object, Movie
, with the following constructor:
public Movie(string title, int year = 0, Genre genre = Genre.None, int length = 0, IEnumerable<string> actors = null) { ... }
There is no ID parameter, as there couldn't be a way to know up front what the ID would be. Movie
does have an int Id
property.
This object would be sent to my MovieRepository
, which uses NHibernate. The repository has a method for adding movies: void AddMovie(Movie movie) { ... }
.
Suppose I want to interact with the object after it is inserted, perhaps to display the data or change properties. I would need the object with the Id
property set, or would need to know the ID generated by the database.
Should I change my AddMovie
method to return the same movie with the ID set, or should I return the resulting ID value? Or perhaps something else?