This project has moved and is read-only. For the latest updates, please go here.

SQLServer2008 Provider to LINQ

Topics: SharpMap Project
May 27, 2010 at 8:04 AM

Hi all,

I got a task in my company to convert SharpMap SQLServer2008 Provider to LINQ and I face many problems in this conversion

If you can give me guidelines ,please support me


Mohammed Thabet Zaky

May 27, 2010 at 11:33 AM

Hi Mohammed, which version of sharpmap is this for? Either way it is likely to be a big job. Linq is probably best used when dealing with domain objects/entities rather than IDataRecords (though there is the Linq to DataSet) currently both 0.9 and v2 use FeatureDataTables internally which are derived from DataTable. We are considering changing v2 to use spatial entities internally though this has consequences when dealing with data from datasources with an arbitary schema. V2 has Expresssions which should make creating a generic linq provider slightly easier.

If you are trying to do this for 0.9 it may be easier to change SharpMap to use IEnumerable<SomeSpatialEntity> internally  (instead of FeatureDataTable) and then use an existing ORM solution (NHibernate, Entity Framework, LinqToSql etc) to actually interact with the data.
Beware that most ORMs do not have any spatial awareness so you would have to extend the providers.

For NHibernate you can use 

There is an article at about using DevArt with Entity Framework.

It has been a long time since I used LinqToSql but if I remember correctly it did have awareness of CLR types so it should work out of the box with spatial types.

If you really want to make a Linq provider you should take a look at and perhaps and possibly also the source for NHibernate

hth jd



May 27, 2010 at 12:41 PM


Thank you for your support .

I actually begin the first steps in this task and I used LINQ2SQL as ORM and I faced a problem of spatial data ,so I convert Geom column to binary as I cannot map it then in C# I used  GeometryFromWKB to convert it again to geom and I overcome most of problems but I have now an exception that I cannot explain to you :D:D

Thank you again for your support and great tutorials that help me

Mohammed Thabet Zaky