Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8759345
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T14:46:45+00:00 2026-06-13T14:46:45+00:00

I tried: var doctorPractise = from d in db.DoctorsPrivateClinics where GetDistance(db, d)<1.0 select d;

  • 0

I tried:

 var doctorPractise = from d in db.DoctorsPrivateClinics
                                     where  GetDistance(db, d)<1.0
                                     select d;

But this doesn’t work, GetDistance is a local function, I didn’t get an exeption but it didn’t seem to work, any ideas?
Thank you

The GetDistance is:

 private double GetDistance(DBClassesDataContext db, DoctorsPrivateClinic docPra)
    {
        double distance=-1;
        double longitude;
        double latitude;

        var city = from c in db.Cities
                   where c.Code == Convert.ToInt32(Request.QueryString["Area"])
                   select c;


        foreach (var cit in city)//it will be just one row that will be found but I don't know how to express it without foreach
        {
            Calculations.GetLongitudeLatitudeGoogle getLongLat = new Calculations.GetLongitudeLatitudeGoogle();
            getLongLat.GetLongitudeLatitude("", cit.Name, "", out longitude, out latitude);
            distance = CalcualateDistance(Convert.ToDouble(docPra.PrivateClinic.Latitude), Convert.ToDouble(docPra.PrivateClinic.Longtitude), latitude, longitude);
        }
        return distance;
    }

What I want to achieve is to calculate the distance between a specific point on the map (cit.Name) and the location of a private clinic. The longitude and latitude of the specific point on the map is been retrieved from Googlemaps. In my query I specify that this distance must be less than 1 Km

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T14:46:46+00:00Added an answer on June 13, 2026 at 2:46 pm

    The trouble is that your query is being translated into SQL by the LINQ provider (EF/Linq2Sql?). It’s not capable of translation of arbitrary .net methods. The only way round this is to enumerate the entire collection locally, dispensing with the database goodness of indexes etc, and probably bottlenecking on network IO from the DB.

    If this isn’t a problem:

    var doctorPractise = from d in db.DoctorsPrivateClinics.AsEnumerable()
                                     where  GetDistance(db, d)<1.0
                                     select d;
    

    otherwise, consider restating your query in terms that can be translated to SQL. Seeing your GetDistance method would help us to help you here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've tried this two ways. Way 1 function Login() { var email = encodeURIComponent($(#loginemail).val());
I have var row=<tr><td>val</td><td>val2</td></tr> and I tried this: $(#mainTable tbody).append(row); but it appends to
Tried : var a=10.3; var b=2.3; alert(a+b); but I get 12.600000000000001 . I know
This is driving me crazy, what is the reason this doesn't work? var name
I tried: var sub_window = window.open(url); sub_window.onunload = function(){ console.log(sub window closed); }; but
I have tried: var url = '/files/123.txt'; $('a').click(function(e) { e.preventDefault(); //stop the browser from
In HTML: <select name=site[new][fw][version]></select> In jQuery, I've tried: var fwvs=$('select[name=site\\[new]\\[fw]\\[version]]') But fwvs.length return 0.
i've got this $('#div').attr(hidden, true); i tried: var a = $('#div').attr(hidden); var b =
I saw this post Linq int to string , and tried it var personalInfoQuery
I would like to call a webservice from javascript. I tried: var locator =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.