question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Examples of spatial types and linq2db

See original GitHub issue

I’ve spend quite some time trying to figure out how to use linq2db in combination with sql server spatial types. I’m in the need of an example how to achieve this. I’ve just upgraded from an old version of linq2db (1.0.6)

POCO:

[Table(Name = "[MyTable]")] 
public class MyTable
{
       // other properties

        [Column(Name ="HomeLocation"), Nullable]
        public SqlGeography HomeLocation { get; set; }
}

Fetching data:

using (var db = new MyDatabase())
{
      var query = from o in db.MyClasses
      select o;
      return query.ToList();
}

Generated query seems allright!

-- MyDatabaseContext SqlServer.2012
SELECT
	-- other properties are ok
	[o].[HomeLocation]
FROM
	[MyTable] [o]

Exception is thrown: Can't create 'MyDatabase.sys.geography' type or '' specific type for HomeLocation.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:17 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
MaceWinducommented, Aug 2, 2019

Glad to hear! I will reopen it as we still need to update documentation on our side

0reactions
MaceWinducommented, Aug 7, 2019

Resolved by https://linq2db.github.io/articles/FAQ.html#how-can-i-use-sql-server-spatial-types Also #1843 will add xml-doc comments with that link

Read more comments on GitHub >

github_iconTop Results From Across the Web

General | Linq To DB
Spatial types for SQL Server provided by: ... Linq To DB will automatically locate required types. You can register types assembly in Linq...
Read more >
linq to sql - Spatial data types support in Linq2Sql or EF4
Here's a workaround to get it working in Entity Framework / LINQ to Entities: You can use a database View to return Well-Known-Text...
Read more >
Spatial - Code First - EF6
This video shows how to map spatial types with Entity Framework Code First. It also demonstrates how to use a LINQ query to...
Read more >
Spatial Data Type in Entity Framework
MS SQL Server 2008 introduced two spatial data types, geography and geometry . The geography type represents data in a round-earth coordinate system...
Read more >
Entity Framework Core 3.1: Spatial Queries – Nearby Places
Spatial data is the data about the location of places. In our case, we are interested in the location of places on our...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found