Wrox Programmer Forums
|
ASP.NET 4 General Discussion For ASP.NET 4 discussions not relating to a specific Wrox book
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 4 General Discussion section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 18th, 2013, 02:46 PM
Registered User
 
Join Date: May 2013
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default MVC 2 ApplyOriginalValues

Hello everyone, this is my first post on the forum.

I'm learning MVC 2 with the Wrox Visual Studio 2010 and .Net 4 (six in one) book.

I'm a bit confused when i have to use "ApplyOriginalValues".

I've detach, then a new attach and finally ApplyOriginalValues.

C# Code from the Wrox book
Code:
context.Books.ApplyOriginalValues(
new Book { Id = editedBook.Id });
The code is working. But the question is: Why a New entity needs to be created?

My vb code is :
Code:
                    context.Books.Attach(editedBook)
                    Dim newBook As New Book
                    newBook .Id = editedBook.Id
                    context.Books.ApplyOriginalValues(newBook)
                    context.SaveChanges()

Thanks a lot for your help.

Last edited by Montero; May 18th, 2013 at 02:50 PM..





Similar Threads
Thread Thread Starter Forum Replies Last Post
Errors while upgrade theBeerHouse mvc project form asp.net mvc 1.0 to 2.0 vanbach1304 BOOK: ASP.NET MVC Website Programming Problem Design Solution ISBN: 9780470410950 0 April 20th, 2010 06:43 AM
MVC tedr BOOK: ASP.NET MVC Website Programming Problem Design Solution ISBN: 9780470410950 4 February 5th, 2010 11:43 AM
TheBeerHouse MVC preview ASP.NET MVC Website Programming Problem Design Solution jminatel BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 5 July 18th, 2009 09:16 AM
mvc datta123 Struts 1 October 26th, 2006 11:00 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.