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
| 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 May 5th, 2011, 08:18 AM
Registered User
 
Join Date: May 2011
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default EDMFunction on Page 140

Hi All:
I keep getting this compile error after adding the EdmFunction on pg. 140.

System.Data.Metadata.Edm.EdmFunction' is not an attribute class

I'm using VS 2008. Do I need VS 2010??? I've done some Googling to no avail

Here is my DinnerRepository.cs in case...

Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Metadata.Edm;
using System.Data.Objects.DataClasses;

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.AddToDinners(dinner);
        }

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

        public void Save()
        {
            entities.SaveChanges();
        }

        // Helper Methods

        [EdmFunction("NerdDinnerModel.Store", "DistanceBetween")]
        public static double DistanceBetween(double lat1, double long1, double lat2, double long2)
        {
            throw new NotImplementedException("Only call through LINQ expression");
        }
    }
}
Thanks for looking.
  #2 (permalink)  
Old May 5th, 2011, 09:29 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

Error in the book. Do this:
Code:
	[EdmFunction("NerdDinner.Models.Store", "DistanceBetween")]
  #3 (permalink)  
Old May 5th, 2011, 09:43 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

Actually, that won't fix your problem. But you'll need to do that anyway.
  #4 (permalink)  
Old May 5th, 2011, 09:44 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

Check to see if you have .NET Framework 4

http://www.microsoft.com/net/

Last edited by flyinhawaiian; May 5th, 2011 at 09:49 AM..
  #5 (permalink)  
Old May 5th, 2011, 12:54 PM
Registered User
 
Join Date: May 2011
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes, I believe I do. This directory exists under C:\WINDOWS\Microsoft.NET\Framework

v4.0.30319

Is this the most current version?

Do I need to change anything in my web.config to make sure I am utilizing this?
  #6 (permalink)  
Old May 5th, 2011, 02:32 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

Delete this line:

using System.Data.Metadata.Edm;
  #7 (permalink)  
Old May 5th, 2011, 03:19 PM
Registered User
 
Join Date: May 2011
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for sticking with this.

After deleting that line, I now have two errors...

Error 1 The type or namespace name 'EdmFunctionAttribute' could not be found (are you missing a using directive or an assembly reference?)

Error 2 The type or namespace name 'EdmFunction' could not be found (are you missing a using directive or an assembly reference?)

As I mentioned before, I did lots of Googling and I ended up figuring out that if I include...

using System.Data.Metadata.Edm;

I am able to get rid of at least one of the errors. That's why it's in there.
  #8 (permalink)  
Old May 5th, 2011, 04:10 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

I don't have that line at all. Edm stuff is supposed to be in
using System.Data.Objects.DataClasses;

Perhaps your EntityFramework is out of date.

Download EntityFramework 4
  #9 (permalink)  
Old May 5th, 2011, 04:25 PM
Registered User
 
Join Date: May 2011
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'm pretty sure I had EF installed already. I went ahead and re-installed from the link you provided and restarted.

Still have the error.

Are you using VS 2008 or VS2010?
  #10 (permalink)  
Old May 5th, 2011, 04:31 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

Hmmmm. I'm using VS 2010 Ultimate. Don't think it should make a difference.

[revision] Actually it does make a difference. VS 2008 does not support 4.0 framework.

Last edited by flyinhawaiian; May 6th, 2011 at 11:09 AM.. Reason: mistake
 


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
PDF giving first page as blank if page count > 1 using xsl:fo srmxslca XSLT 14 May 5th, 2011 05:01 AM
Page 210:Page object calling a private method from BasePage? aperture8 BOOK: Beginning ASP.NET 4 : in C# and VB 6 August 9th, 2010 07:04 AM
Stuck At Page 140 Yap Dreamweaver (all versions) 2 October 12th, 2004 06:49 PM



All times are GMT -4. The time now is 01:55 AM.


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