Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > Other .NET > BOOK: Professional LINQ
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Professional LINQ
This is the forum to discuss the Wrox book Professional LINQ by Scott Klein; ISBN: 9780470041819
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional LINQ section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Display Modes
  #1 (permalink)  
Old September 9th, 2009, 01:02 PM
Authorized User
 
Join Date: Sep 2009
Location: Everett, WA
Posts: 12
Thanks: 1
Thanked 0 Times in 0 Posts
Red face pg 267 Transaction Example Code

Hello, I wrote some code utilizing information contained int the example on a fore mentioned page I received an error "does not contain a definition for Add...are you missing... an assembly reference. I downloaded the coded example in hopes of finding the solution, but alas I received the same error message for all "db.Contacts.Add". So what am I missing here?
  #2 (permalink)  
Old September 9th, 2009, 08:57 PM
SQLScott's Avatar
Wrox Author
 
Join Date: Dec 2004
Location: Wellington, FL , USA.
Posts: 338
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Hi,

The solution is to use the InsertOnSubmit method. I'm not sure when this was changed, and I will find out, but the code below shows how this is used:

Code:
try
{
using (TransactionScope ts = newTransactionScope())
{
AdventureWorksDataContext context = newAdventureWorksDataContext("Integrated Security=SSPI");
Person p = newPerson
{
FirstName = "",
LastName = ""
};
context.Persons.InsertOnSubmit(p);
context.SubmitChanges();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}

__________________
========================
Scott Klein
Author of:
Professional SQL Server 2005 XML
Professional WCF Programming: .NET Development with the Windows Communication Foundation
Professional LINQ
========================
  #3 (permalink)  
Old September 9th, 2009, 09:57 PM
Authorized User
 
Join Date: Sep 2009
Location: Everett, WA
Posts: 12
Thanks: 1
Thanked 0 Times in 0 Posts
Wink Used through out in the book

Thanks for the information.
Just so we are clear. It is not only the examples that are trying to use the add method to insert, but that is also what is printed in the book. Without whining too much, I can tell you I spent a lot of time with my code trying to figure out what was missing because I trust that a WROX book is going to be accurate and trust worthy. I understand that mistakes occur, Lord knows I have made more than my fair share, but the book has been out for sometime and this erroneous statement occurs in many places. I will go back and look, but I do not remember seeing an addendum of corrections. Forgive me if my ignorance is causing me to be too critical. I guess what I am trying to ascertain at this point is: 1)at what point should I question the accuracy of the information in a WROX book. Would it be premature of me to post a question as soon as I have tried something based on the information provided and failed to get the intended result or how much time should I spend questioning my own context in which I've utilized the examples before I question the book itself. 2)Is there a quick method for determining whether the information provided is correct or not in order to avoid exposing the possibility that the error was mine and wasting everyone's time? 3) Is this not all that important as such errors in Wrox books are rare? Thanks again for a timely response to my problem.
  #4 (permalink)  
Old September 9th, 2009, 11:32 PM
SQLScott's Avatar
Wrox Author
 
Join Date: Dec 2004
Location: Wellington, FL , USA.
Posts: 338
Thanks: 0
Thanked 2 Times in 2 Posts
Default

I appreciate your comments. Great feedback. Keep in mind that most books like these are are written with Beta 1 and early Beta 2 bits, so things like this, things that you are finding, occur. So, let me answer your questions this way:
1) You have every right to post a question to the publisher and even author the second you find a non-working example. I would preface this, however, like you have done, you spend a few minutes making sure that you have "questioned your own context". For example, in this case, the Add method doesn't even exist and therefore I would be posting a question almost immediately.
2) There is not a blank and white answer here, but even I as a reader expect examples to work but know that releases change and what worked in one release won't work in another. I don't think there is a quick method, but I typically post a question to the author or forum after I have tried a few things on my own or have done a few BING/Google searches. There are also things that are out of our control.
For example, I have recieved a number of emails from readers who purchased my WCF book. Many of the examples worked up until they applied a Windows update then all of a sudden the examples quit working. At that point I just throw up my hands and say "what the...?" and ask Microsoft about it.
3) This is a tough one. I love writing books, but I hate using early beta releases to use for examples. The problem is publishers want to be the first out, and to go through all the examples again right before the book goes to publication with the latest release is very time consuming. And we as readers hope that mistakes like this are rare.

I think the answer likes on both sides. I need to be better at providing addendum's for the book. I'll focus on that. You and every other reader are free to email me asking questions such as this. Because things like this keep me in check and more importantly keep me honest. :-)

Hope this helps...
__________________
========================
Scott Klein
Author of:
Professional SQL Server 2005 XML
Professional WCF Programming: .NET Development with the Windows Communication Foundation
Professional LINQ
========================
  #5 (permalink)  
Old September 10th, 2009, 12:24 PM
Authorized User
 
Join Date: Sep 2009
Location: Everett, WA
Posts: 12
Thanks: 1
Thanked 0 Times in 0 Posts
Smile One Final Word

I can can definitely demonstrate some empathy regarding Microsoft debilitating a perfectly fine application with an update.
Thanks for your commitment to excellence and your willingness to share your knowledge with others.
 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
C# Ch.8 try it now on pg266-267 sdc151 BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 9 December 17th, 2008 12:55 PM
Code chapter 5 pg 145-146 PHP Newb BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 3 August 25th, 2006 09:33 PM
quick question about code on pg 171 phpnewbie BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 2 August 24th, 2004 12:51 PM
CH 6 pg 216 Recursive Code wadesmart BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 8 November 19th, 2003 07:53 PM



All times are GMT -4. The time now is 02:16 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.