views:

1428

answers:

4

I have been tasked with porting our .NET Desktop application to a mobile device. Our desktop application uses LINQ to SQL to interact with the database. However, LINQ to SQL is not available on mobile devices. We develop for Windows Mobile 5 and 6.

I am debating between suggesting a different ORM that supports both desktop and mobile out of the box (http://www.entityspaces.net/portal/ seems the best to me). However, since our databases are relatively small (one of them is relatively simple at 10 tables; the other is 27 tables but the associations are more complex), I am leaning more towards just re-coding the domain objects and data access functions myself.

Has anyone else been in this situation? What choice did you make?

+2  A: 

I can personally recommend LLBLGen. They have CF Framework support for v1.0 & 2.0. It's very quick to map tables and the resulting entities can be used in both mobile and desktop. It's also not expensive, and has a long track record. Based on your requirements, that would be the quickest way there. Doing it in POCOs (Plain Old CLR Objects) and using Linq to Objects would be doable, but would take much longer.

chris.w.mclean
+1  A: 

Here are two more options for you:

http://www.llblgen.com/defaultgeneric.aspx

http://www.devexpress.com/Products/NET/ORM/info.xml

Personally, I've never used LINQ to Sql on a the Compact Framework, the only thing I've done that's close was use Linq to Sql against SqlCe on the desktop.

Now depending on how bug your data layer is, it may be worth seeing if you can use any of those ORM's and see how much of your existing code is reusable, or it may very well be worth to just rewrite it (again, depending on the size of the project)

BFree
+1 for giving us lazy folks the actual link to llblgen
ctacke
he has never used LINQ to Sql on the Compact Framework because it is not supported.
trampster
+1  A: 

My team is using T4 to generate basic CRUD operations based on the structure of the database and the conventions we use to map our POCO classes and properties to SQL Compact tables and columns. It is a bit of work, but is working out OK.

Eric Farr
Thanks. I decided to use POCO classes/properties with LINQ to Objects as the DB is not too big. I will take a look into T4 as this may make it easier for us.
chocojosh
A: 

you can't use linq to sql directly with SqlServerCE. with CF you only have the linq to Xml, Linq to DataSet and Linq to objects flavours available. I'm working on a mobile app and because I'm consuming data with a SqlCeResultSet object, and because this object implements IEnumerable you can use Linq with it.

maybe this can help you out

http://www.pluralsight.com/community/blogs/jimw/archive/2008/02/27/50325.aspx

Bee gud
Interesting. I'm not an expert on performance with ADO.NET. Right now I'm using a SqlCeDataReader to iterate through results and create a List<Domain_Object> as List<> can be used with LINQ. Planning on using lazy load also to help performance.
chocojosh