I have a constructor signature that looks like this.
public LocateEditorViewModel(
ILocateRepository locateRepository,
int id,
IInteractionService interactionService)
{
As the class name suggests this is the view model I use to edit locates. This view model is created from a factory that injects ILocateRepository
and IInteractionService
. The id is passed in the factories Create(int id)
function.
Is it the job of the LocateEditorViewModel
to receive and id
of the item I wish to edit and query it from the database. Or should I query for the given item in my factory and replace my int id
parameter into a LocateViewModel
object?
The ViewModel works on the data of the Model which in turn accesses the database. The ViewModel does not access the database.
So: Yes, you should replace the id with the actual object.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.