Wrox Programmer Forums
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
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?

        //[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."

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.
Old January 24th, 2011, 02:22 PM
Friend of Wrox
Join Date: Oct 2010
Posts: 106
Thanks: 1
Thanked 17 Times in 17 Posts

Might try looking at NerdDinner V1.
The Following User Says Thank You to flyinhawaiian For This Useful Post:
Olin (January 24th, 2011)
Old January 24th, 2011, 04:49 PM
Registered User
Join Date: Jan 2011
Posts: 9
Thanks: 2
Thanked 0 Times in 0 Posts

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.

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

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.