Answered by:
MVVM Repository Pattern in VB.net

Question
-
Trying to implement the repository pattern in vb.net using the following as a guide: Proper way to update records in MVVM pattern for maximum effeciency
For some reason When I run SaveCars the loop for:
For Each changedItem As Car In _cars.GetChangedItems().Intersect(cars)
Console.WriteLine(changedItem.Make)
NextGives me nothing....
I have zipped my project here: http://dl.dropbox.com/u/4086656/RepositoryPatter.zip
Or for the code:
Model : https://gist.github.com/2065055
Repository: https://gist.github.com/2065065
ChangeTracker: https://gist.github.com/2065076
VM/View (Console): https://gist.github.com/2065097
Saturday, March 17, 2012 8:50 PM
Answers
-
Hi Omar,
I went through your code and you only need to make a slight change to make it get changed records correctly -
Public Function IsChanged(ByVal copy As T) As Boolean Dim original = _originals(_copyIndex(copy)) Return Not original.Equals(copy) End Function
I only had to add the word "NOT" in the return statement.
- Proposed as answer by Sheldon _Xiao Monday, March 19, 2012 7:25 AM
- Marked as answer by Omar Mir Monday, March 19, 2012 12:52 PM
Sunday, March 18, 2012 9:52 AM
All replies
-
Hi Omar,
I went through your code and you only need to make a slight change to make it get changed records correctly -
Public Function IsChanged(ByVal copy As T) As Boolean Dim original = _originals(_copyIndex(copy)) Return Not original.Equals(copy) End Function
I only had to add the word "NOT" in the return statement.
- Proposed as answer by Sheldon _Xiao Monday, March 19, 2012 7:25 AM
- Marked as answer by Omar Mir Monday, March 19, 2012 12:52 PM
Sunday, March 18, 2012 9:52 AM -
Right! Works - what about Overriding GetHasCode - needs to be done for sure here?Monday, March 19, 2012 1:20 AM
-
Hi Omar,
I'm not sure why you want to override the GetHashCode? I'm not sure what you want to achieve by it. But i think the original question has been answered. It would be fair (in my opinion) for you to close this thread and ask that question in a new thread.
Thanks.
Monday, March 19, 2012 10:23 AM -
Thanks Omar. That's really appreciated.Monday, March 19, 2012 1:42 PM