Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| 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
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 22nd, 2010, 03:39 AM
Registered User
 
Join Date: Dec 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default NerdDinner

Hi all,

I am very new to MVC. just started learning from past few days. Was previously java developer. I am using professional ASP.NET MVC 2 . I was designing NerdDinner site and when i designed this Dinner.cs as told in the book, i started getting erros in DinnerRepository.cs saying

Error 1 Cannot implicitly convert type 'System.Data.Objects.ObjectSet<NerdDinner.Dinner>' to 'System.Linq.IQueryable<NerdDinner.Models.Dinner>' . An explicit conversion exists (are you missing a cast?)

i know i am missing something simple but i am not able to put it right. can anyone help me?


Thanks in advance
  #2 (permalink)  
Old December 22nd, 2010, 03:00 PM
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

Please post your code and I'll try to figure it out.
  #3 (permalink)  
Old December 23rd, 2010, 12:59 AM
Registered User
 
Join Date: Dec 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

*********** Dinner Repository **************

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;

namespace NerdDinner.Models
{
public class DinnerRepository
{
private NerdDinnerEntities entities = new NerdDinnerEntities();
//
// Query Methods
public IQueryable<Dinner> FindAllDinners()
{
return entities.Dinners;
}
public IQueryable<Dinner> FindUpcomingDinners()
{
return from dinner in entities.Dinners
where dinner.EventDate > DateTime.Now
orderby dinner.EventDate
select dinner;
}
public Dinner GetDinner(int id)
{
return entities.Dinners.FirstOrDefault(d => d.DinnerID == id);
}
//
// Insert/Delete Methods
public void Add(Dinner dinner)
{
entities.Dinners.AddObject(dinner);
}
public void Delete(Dinner dinner)
{
foreach (var rsvp in dinner.RSVPs)
{
entities.RSVPs.DeleteObject(rsvp);
}
entities.Dinners.DeleteObject(dinner);
}
//
// Persistence
public void Save()
{
entities.SaveChanges();
}
}
}


************* Dinner.cs ***************

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;

namespace NerdDinner.Models
{

[MetadataType(typeof(Dinner_Validation))]
public partial class Dinner {
//…
}
public class Dinner_Validation
{
[Required(ErrorMessage = “Title is required”)]
[StringLength(50, ErrorMessage = “Title may not be longer than 50 characters”)]
public string Title { get; set; }
[Required(ErrorMessage = “Description is required”)]
[StringLength(265, ErrorMessage =
“Description must be 256 characters or less”)]
public string Description { get; set; }
[Required(ErrorMessage = “Address is required”)]
public string Address { get; set; }
[Required(ErrorMessage = “Country is required”)]
public string Country { get; set; }
[Required(ErrorMessage = “Phone# is required”)]
public string ContactPhone { get; set; }
}
}
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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
NerdDinner ViewModel Errata Darthus BOOK: Professional ASP.NET MVC 2 10 September 20th, 2010 01:02 PM
NerdDinner Example Phils_UK BOOK: Professional ASP.NET MVC 2 1 July 6th, 2010 07:49 PM
Chapter 1 - NerdDinner - Errors Steve S BOOK: Professional ASP.NET MVC 1.0 ISBN: 978-0-470-38461-9 17 May 22nd, 2010 03:22 PM
NerdDinner The view 'Index' or its master could not be found rthorington BOOK: Professional ASP.NET MVC 1.0 ISBN: 978-0-470-38461-9 3 May 3rd, 2009 04:30 PM
NerdDinner.Tests Project Missing Stuff dwrogers BOOK: Professional ASP.NET MVC 1.0 ISBN: 978-0-470-38461-9 2 March 22nd, 2009 09:54 AM



All times are GMT -4. The time now is 05:54 PM.


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