View Single Post
  #2 (permalink)  
Old January 2nd, 2011, 10:47 PM
Rushino Rushino is offline
Friend of Wrox
 
Join Date: Mar 2010
Posts: 99
Thanks: 21
Thanked 6 Times in 4 Posts
Default

What the hell. I sent an email to Wrox regarding this errata and got answered this :

Thank you for contacting Wiley Technical Support. Information about the code on page 30 can be found at:

http://www.wiley.com/WileyCDA/WileyT...Cd-ERRATA.html

code snippet 1-3.txt
This code snippet is designed to illustrate the associated concepts and is not designed to be complied. There are no errors in it but it will not run.


Please let us know if you have any more questions.


There IS an error in this code... how this fellowing code is supposed to be logical and free of any errors ?

public void Delete(Dinner dinner) {
foreach (var rsvp in dinner.RSVPs) {
entities.RSVPs.DeleteObject(dinner.RSVPs);
}
entities.Dinners.DeleteObject(dinner);
}

You actually tell to delete the collection of RSVPs while looping through it.. furthermore.. deleteObject accept only an rsvp entity so it should be a single rsvp.

The logical way should be delete all RSVPs associated by the dinner and delete the dinner.

Anyone could reply telling that i am correct ?

Thanks.