I use Linq-to-SQL to create my models. I have a Movies table that lists all of the users' favorite movies.
In my VM, I'll have access to a current user. I want to call to my linq entity to get all the users favorite movies. Is it bad practice to have the actual linq query to the Movies table directly in a method in my VM?
Public Class MyVM
Public Sub GetMovies()
'some linq query to get the movies based on the user's id
End Sub
...more stuff...
End Class
Or, should I have that method in my model and only call a GetAll(ByVal id as Integer)
function from the model or a repository?
I'm pretty new to patterns. I know patterns are more of a guide, but I'd like to follow it correctly before I make those determinations when the situation arises.
A view model is there to represent your data, for example on a view (in ASP.NET MVC).
For example lets say you have a view that has to display user data. You will return a User object by ID from a service or repository call (to a database). You will then map this User object to the view model. Then you would return this view model to the view and the view will use it to display the user's data to the client.
If I could then I could show you some C# code. I don't have time to go look up the VB.NET equivalent.