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
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 24th, 2011, 01:59 PM
Registered User
 
Join Date: Jan 2011
Posts: 9
Thanks: 2
Thanked 0 Times in 0 Posts
Default Entity Framework v1 issue

I am not able to upgrade to the new Entity Framework (4.0) so I have to use the first version (EFv1). Up to now I have been able to get by, but I am now stuck at the part where the LINQ query is trying to use the DistanceBetween database funcion in the where clause. Also note that I had to comment out the EdmFunctionAttribute - I believe that is an EFv4 feature only. Is there a way to do it in EFv1?


Code:
        //[EdmFunction("NerdDinner.Models.Store", "DistanceBetween")]
        public static double DistanceBetween(double lat1, double long1, double lat2, double long2)
        {
            throw new NotImplementedException("Only call through LINQ expression");
        }

        public IQueryable<Dinner> NearestDinners(double latitude, double longitude)
        {
            return from d in entities.Dinners
                   where DistanceBetween(latitude, longitude, d.Latitude, d.Longitude) < 100
                   select d;
        }

I get the following error:

System.NotSupportedException was unhandled by user code
Message="LINQ to Entities does not recognize the method 'Double DistanceBetween(Double, Double, Double, Double)' method, and this method cannot be translated into a store expression."
Source="System.Data.Entity"


From what I've read, EFv1 does not support database functions, which seems like a major shortcoming if true. Does anyone have any ideas how I can get this to work? Thanks in advance.
  #2 (permalink)  
Old January 24th, 2011, 02:22 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

Might try looking at NerdDinner V1.
http://aspnetmvcbook.s3.amazonaws.co...rdinner_v1.pdf
The Following User Says Thank You to flyinhawaiian For This Useful Post:
Olin (January 24th, 2011)
  #3 (permalink)  
Old January 24th, 2011, 04:49 PM
Registered User
 
Join Date: Jan 2011
Posts: 9
Thanks: 2
Thanked 0 Times in 0 Posts
Default

Thanks FH, but unfortunately the first MVC tutorial uses LINQ to SQL. I am getting Visual Studio 2010 tomorrow, so hopefully using EFv4 will resolve my issues.
 


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
Entity Framework And MVC geomar BOOK: Professional ASP.NET MVC 1.0 ISBN: 978-0-470-38461-9 5 January 24th, 2011 04:58 PM
Entity Framework vs datasets? hoss BOOK: Beginning ASP.NET 4 : in C# and VB 1 September 30th, 2010 02:42 AM
Switching To entity framework luckystar BOOK: ASP.NET 3.5 Enterprise Application Development with Visual Studio 2008: Problem Design Solutio 0 July 31st, 2009 09:52 PM
.NET Framework v1.1 NemeSYS VS.NET 2002/2003 3 September 17th, 2003 10:18 PM



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


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