Dinner and RSVP classes

May 11, 2009 at 7:26 PM

I have downloaded NerdDinner tutorial and have started following it with creating a project and NerdDinner database.

I dropped Dinner and RSVP tables on NerdDinner designer surface.

But I do not see related classes in NredDinner project in any of the Models/Views/Controllers folder or in any other folders.

How can I see these classes OR what should I do to see these classes?

I have created NerdDinner mdf and ldf data files are in project folder.

Your guidnece will help me move forward.

Thank you in advance.

Bharat Gadhia.

 

May 12, 2009 at 12:37 PM

Hi Bharat,

You need to drag and drop the database tables Dinner and RSVP to .dbml (LINQ to SQL) file's designer surface. You need to add a new Item in Models directory. Follow the below mentioned steps to achieve this.

1. Right click on Models folder. Choose Add New Item.

2. Under "Visual C#" node choose "Data" node and select "LINQ to SQL classes". Enter the name for the file.

3. Now drag and drop the database tables in this file.

Your Dinner and RSVP classes will be created.

Let me know if you face any problem.

Thanks
Nitin Arora

 

 

May 12, 2009 at 3:56 PM
Edited May 12, 2009 at 3:58 PM

Hi Nitin,

Thank you for your reply.

I think I found the ansrwer to my question. It seems that these two classes are contained inside NerdDinner.Designer.cs filesinside Models folder. This file also contains the

NerdDinnerDataContext  class.

Once you create an object of type NerdDinnerDataContext you can access properties of Dinner and RSVP classes.

Like:-

 private NerdDinnerDataContext db = new NerdDinnerDataContext();

This was not clearly mentioned in Tutorial either.

Thanks,

Bharat.

May 20, 2009 at 1:41 AM
Edited May 20, 2009 at 4:03 AM

Edit: Nothing to see here, Move along now... User error responsible for below question.


I have another newbie question.

If I follow the directions in Chapter 1 (up to pg33) in building the application, I get stuck trying to complete the DinnerRepository.cs file. I must be missing an unlisted step.

The problem is that the RSVPs collection is not recognized because the LINQ2SQL class generator doesn't generate the classes properly. For the Dinner class, it doesn't create private EntitySet<RSVP> _RSVPs; as part of the Dinner class, nore does it add this._RSVPs = new EntitySet<RSVP>(new Action<RSVP>(this.attach_RSVPs), new Action<RSVP>(this.detach_RSVPs)); to the Dinner constructor. It also fails to add:

[

Association(Name="Dinner_RSVP", Storage="_RSVPs", ThisKey="DinnerID", OtherKey="DinnerID")]

public EntitySet<RSVP> RSVPs

{

get  { return this._RSVPs; } set {this._RSVPs.Assign(value); } }

 

It also fails to add similar lines to the RSVPs class.

Is there something I'm missing about configuration of the LINQ2SQL tool. Otherwise everything else is the same. Obviously I'd rather not add these lines manual in case I want to regenerate the classes again.

Any hints?

 

Microsoft Visual Studio 2008 Version 9.0.30729.1 SP
Microsoft .NET Framework Version 3.5 SP1  Installed Edition: Professional

My LINQtoSQL class generator tool is: Runtime Version:2.0.50727.4918

where the version from the codeplex source is generated by: Runtime Version:2.0.50727.3521

 

Coordinator
May 20, 2009 at 7:43 AM
This makes me think that the database itself doesn't have the reference between the the Dinner table and the RSVP table...if that PK/FK reference was there, the L2S would generate correctly.

On Tue, May 19, 2009 at 6:41 PM, tmc2k <notifications@codeplex.com> wrote:

From: tmc2k

I have another newbie question.

If I follow the directions in Chapter 1 (up to pg33) in building the application, I get stuck trying to complete the DinnerRepository.cs file. I must be missing an unlisted step.

The problem is that the RSVPs collection is not recognized because the LINQ2SQL class generator doesn't generate the classes properly. For the Dinner class, it doesn't create private EntitySet<RSVP> _RSVPs; as part of the Dinner class, nore does it add this._RSVPs = new EntitySet<RSVP>(new Action<RSVP>(this.attach_RSVPs), new Action<RSVP>(this.detach_RSVPs)); to the Dinner constructor. It also fails to add:

<font size="2">

[

</font>

Association(Name="Dinner_RSVP", Storage="_RSVPs", ThisKey="DinnerID", OtherKey="DinnerID")]<font size="2">

 

</font>

public EntitySet<RSVP> RSVPs<font size="2">

{

</font>

get  { return this._RSVPs; }<font size="2">

 

</font>

set {this._RSVPs.Assign(value); } }

It also fails to add similar lines to the RSVPs class.

Is there something I'm missing about configuration of the LINQ2SQL tool. Otherwise everything else is the same. Obviously I'd rather not add these lines manual in case I want to regenerate the classes again.

Any hints?

 

Microsoft Visual Studio 2008 Version 9.0.30729.1 SP
Microsoft .NET Framework Version 3.5 SP1  Installed Edition: Professional

My LINQtoSQL class generator tool is: Runtime Version:2.0.50727.4918

where the version from the codeplex source is generated by: Runtime Version:2.0.50727.3521

Read the full discussion online.

To add a post to this discussion, reply to this email (nerddinner@discussions.codeplex.com)

To start a new discussion for this project, email nerddinner@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com




--
Scott Hanselman
http://www.hanselman.com
May 21, 2009 at 5:15 AM

Thanks for answering this Scott. After staring at it for an hour I realized I forgot to set the primary key in the RSVP table.