title: How to Get Closest Location in LINQ to Entities
body: <p>I am trying to get the closest location via my LINQ query:</p>
  
  <pre><code>var coord = new GeoCoordinate(loc.Latitude, loc.Longitude);
  var nearest = ctx.Locations
                   .Select(x =&gt; new LocationResult {
                       location = x,
                       coord = new GeoCoordinate(x.Latitude.GetValueOrDefault(),
                                                 x.Longitude.GetValueOrDefault())
                   })
                   .OrderBy(x =&gt; x.coord.GetDistanceTo(coord))
                   .First();
  
  return nearest.location.Id; 
  </code></pre>
  
  <p>However, I am getting the following error:</p>
  
  <blockquote>
    <p>Only parameterless constructors and initializers are supported in LINQ to Entities.</p>
  </blockquote>
  
  <p>I have tried Googling this but I am still not sure how to fix it.  What is a parameterless constructor?</p>