开发者

Who is responsible for loading data?

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 LocateEditorViewM开发者_如何学编程odel 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜