Hello,
I’m having some issues querying a database table with geography column type using OrmLite and was hoping for some help!
Here’s my database table (in Sql Server):
CREATE TABLE [dbo].[james](
[loc] [geography] NULL,
[id] [int] IDENTITY(1,1) NOT NULL
)
Here’s my c# code:
public class James
{
[AutoIncrement]
public int id { get; set; }
public SqlGeography loc { get; set; }
}
Insert a new row into table:
using (var db = ConnectionFactory.OpenDbConnection())
{
var james = new James()
{
loc = SqlGeography.Point(40.6898329, -74.0452177, 4326)
};
db.Insert(james);
}
Then I verify that new insert succeeded via sql management studio:
SELECT loc.Lat, loc.Long FROM [james].[dbo].[james] WHERE id = 1
=> 40.6898329 -74.0452177
Then unfortunately my OrmLite query isn’t so successful:
using (var db = ConnectionFactory.OpenDbConnection())
{
var result = db.SingleById<James>(1);
// result.loc == null... wuh wuh
}
For some reason I’m not getting the ‘loc’ column value back (it’s null). I suspect that the OrmLite Sql Server converter isn’t behaving as I expect it to but unfortunately I haven’t found any documentation to enlighten me!
Any help would be greatly appreciated!
Thanks,
James