views:

330

answers:

4

Im on to design my Data Access for a new solution i create. That solution though contains Compact Framework Device Application and libraries besides Desktop. All .NET 3.5. Desktop will handle all Data Access basically. I need the Data Objects to have in CF too, Desktop will communicate with SQL and then with Mobile and give the appropriate data...

I love LINQ, and more i love LINQ 2 SQL. There is a lot of hype out there and i don't buy internal Microsoft politics about recommending EF. For now EF is too heavy and too complex for someone to choose it besides it still evolving and EF 4 will have major changes when it comes in a few months. But i cant wait for months to create a project as every developer in here, i want something now! After that said i want to use LINQ 2 SQL, my problem is that i cant just copy the generated dbml and use the generated classes. I don't need the DataContext cause i don't intend to use CRUD or any operations on a database with the Mobile App. i Just want the Objects. Anyone ever came in a situation like this? The whole point is not to write all classes representing the tables by hand. Cause i need them for further LINQ to Objects manipulation.

Basically an ORM supporting CF would do the job! But i don't know any incompatibilities i would meet.

+1  A: 

L2S works great with the compact framework. You can't use the drag-and-drop designer, though. You'll need to run SQLMetal.exe yourself to generate the classes for you.

SQLMetal.exe: http://msdn.microsoft.com/en-us/library/bb386987.aspx

Example with Northwind compact: http://blogs.msdn.com/sqlservercompact/archive/2007/08/21/linq-with-sql-server-compact-a-ka-dlinq-over-sql-ce.aspx

Another example, with lots of pictures: http://pietschsoft.com/post/2009/01/Using-LINQ-to-SQL-with-SQL-Server-Compact-Edition.aspx

Jarrett Meyer
I dont need using an SQL CE Database on my Desktop App, i just need to generate the Classes from Tables, seems that i will make this by hand....
You can run SQLMetal to get the objects from the data store, then edit the *.cs file that gets generated.
Jarrett Meyer
That is an option. Should change all EntitySet and EntityRef into Generic Collections i guess.
A: 

You could use DevExpress persistent objects (XPO) on compact framework. I have used it before but found it to be somewhat slow for my purpose (data collection application).

The reason that you cannot find much of this on the compact framework is that speed is usually so important for device apps, that data access code is usually done manually.

I don't know if you can create objects from an already existing database with XPO.

Thank you for your proposition.
+2  A: 

I've been able to modify SubSonic 3.0, the db4o/Mainsoft port of System.Linq.Expressions from the Mono project after adding the missing Queryable sources, and Matt Warren's IQToolkit on Codeplex to provide a L2S equivalent on the CF.

This is about what it takes, though, since Linq expression trees are not supported on .Net CF 3.5.

I was able to use the DbEntityProvider/DbEntitySession and AttributeMapping/XMLMapping imported to Subsonic from IQToolkit to provide better entity and table-to-class mapping support.

codekaizen
I think this would support on copying the generated objects from the dbml file but i dont have this kind of knowledge. What About System.Data.Linq? In there are the EntitySet<> EntityRef<> Binary data types and all the Attributes i think. If i could support these i think i wont have to write the Business Objects by hand for the devices. Very good post though.
A: 

This is one good option generating from dbml file plain POCO classes working with LINQ 2 SQL. Not tested yet but seems promised.

http://www.codeplex.com/ULinqGen