title: Convert Geometry to Geography against PostGIS with Npgsql and EntityFramework Core
body: <p>In PostgreSQL PostGIS I can get the distance in meters by just casting the geometry column to geography using this syntax inside the sql query &quot;<strong>geometry_column::geography</strong>&quot;. like so :</p>
  <pre><code>select * from &quot;Tags&quot; where ST_Distance(&quot;Location&quot;,'POINT(31.233334 30.033333)'::geography) &lt; 1000 ;
  </code></pre>
  <p>Now I want to convert <strong>tag.Location</strong> and <strong>point</strong> to Geography inside the where function of Linq to get the same result.</p>
  <pre><code>var tags = db.Tags.Where((tag) =&gt; tag.Location.Distance(point) &lt; RangeInMeters )
                  .Select(tag =&gt; new {
                      Id = tag.Id,
                      Title = tag.Title,
                      Coordinates = new double[]{tag.Location.X,tag.Location.Y},
                  });
  </code></pre>
  <p>here's tag.Location definition</p>
  <pre><code>[Column(TypeName=&quot;geometry (point)&quot;)]
  public Point Location{get;set;}
  </code></pre>
  <p>and here's &quot;point&quot; variable definition</p>
  <pre><code>var point = new Point(new Coordinate(Longitude,Latitude));
  point.SRID = 4326;
  </code></pre>