Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4 > BOOK: Professional ASP.NET MVC 2
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Professional ASP.NET MVC 2
This is the forum to discuss the Wrox book Professional ASP.NET MVC 2 by Jon Galloway, Scott Hanselman, Phil Haack, Scott Guthrie, Rob Conery; ISBN: Professional ASP.NET MVC 2
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional ASP.NET MVC 2 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
Reply
 
Thread Tools Display Modes
  #11 (permalink)  
Old March 10th, 2011, 09:37 AM
Friend of Wrox
Points: 539, Level: 8
Points: 539, Level: 8 Points: 539, Level: 8 Points: 539, Level: 8
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2010
Location: Seattle
Posts: 106
Thanks: 1
Thanked 17 Times in 17 Posts
Default

This is the right way
Code:
public void Add(Dinner dinner)
{
	entities.Dinners.AddObject(dinner);
}
But you say you have compiler error? Sounds like you don't have right version of .Net Framework (need .NET Framework 4)

Download here
Reply With Quote
  #12 (permalink)  
Old March 11th, 2011, 02:30 AM
Registered User
 
Join Date: Mar 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Smile entities.AddObject(dinner)

thank´s you for your help flyinhawaiian, the .NET framework 4 I have it installed,automatically installed by Visual Studio 2010 Ultimate.

The problem is that when I try this, does not recognize the method .AddObject()

entities.Dinners.AddObject(dinner)

if I delete .Dinners., and I write entities.AddObject(dinner); it works.


where I can define the method .AddObject() for the Class Dinners????
it´s automatically defined? where I can check?


Thank´s you.
Reply With Quote
  #13 (permalink)  
Old March 11th, 2011, 09:53 AM
Friend of Wrox
Points: 539, Level: 8
Points: 539, Level: 8 Points: 539, Level: 8 Points: 539, Level: 8
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2010
Location: Seattle
Posts: 106
Thanks: 1
Thanked 17 Times in 17 Posts
Default

Should not have to define it yourself. AddObject() is part of ObjectSet class. Your entity might be differently named. I recall an error in the book (Dinners versus Dinner). Review the steps to create the entity and pay careful attention to the name you use.

Or, look in NerdDinner.Designer.cs This is what my Dinners looks like. Don't touch anything in this file, unless you really know what you're doing. It is meant to be changed only by the designer.

Code:
        public ObjectSet<Dinner> Dinners
        {
            get
            {
                if ((_Dinners == null))
                {
                    _Dinners = base.CreateObjectSet<Dinner>("Dinners");
                }
                return _Dinners;
            }
        }

        private ObjectSet<Dinner> _Dinners;
Reply With Quote
  #14 (permalink)  
Old April 13th, 2011, 03:27 AM
Registered User
 
Join Date: Apr 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by Ole F View Post
kermit1965, I guess you will get a problem with your code - especially if there are two (or more) RSVP's to a dinner!

Why? Because in you "foreach" loop you first delete the first rsvp. Then you (within your loop) delete the dinner. I guess your application will crash when going to the next RSVP (or maybe the other RSVP's will just stay in the database undeleted...)
Sorry I was not precise. The code was only creating three methods. I did not intend that they be run sequentially
Reply With Quote
Reply


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
Error on page 38 in DinnerRepository adimauro BOOK: Professional ASP.NET MVC 2 3 July 6th, 2010 07:46 PM
Difficulty with $_SESSION mall9@hotmail.com Beginning PHP 11 March 11th, 2006 04:41 PM
Javascript Confirm dialog difficulty ayrton Javascript 1 May 20th, 2005 03:34 AM
ASCII conversion loop difficulty crmpicco Excel VBA 2 May 3rd, 2005 01:41 PM
Difficulty getting thePhile up and running tkubaska BOOK: ASP.NET Website Programming Problem-Design-Solution 3 April 5th, 2004 12:32 PM



All times are GMT -4. The time now is 09:40 PM.


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