Web Design Nottingham Header

SQL CE and LINQ

Publication Date: Mon 07 Apr 2008

As part of the Malachi project we are developing. A requirement is to have windows applications running on occassionally connected laptops.

Therefore, we had the requirement to store data locally. We didn't want to leave a large footprint, so opted for SQL CE 3.5 as this now supports LINQ.

Creating the schema

First of all we needed to create the database schema, this was the first problem. SQL management studio 2005 only supports sql CE 3.1, so you cannot use it. Luckily VS2008 does support it, but using the limited server explorer view, which did not provide us with something like query analyser to run T-SQL commands in order to execute DDL. SQL server 2008 does support editing CE 3.5, but is still in CTP.

Luckliy, we came across a nice application called Data port console, a trial version for 30 days can be downloaded from here: http://www.primeworks-mobile.com/Downloads/DPCon.html This allows scripts to be run against 3.5 databases.

The next issue was to create the DDL commands, we already had a similar schema on the server side using SQL Server Express edition, which would be storing all the data when the laptops connect, so we scripted the tables out. First I tried to run the exact script, which failed. We then realised that the syntax would obviously be slightly different, for instance there is no varchar datatype just nvarchar in the compact edition. We edited the file and managed to reproduce the schema in the SQL CE database.

Using LINQ

Next we wanted to create a LINQ dbml file from the CE database. After receiving errors from the LINQ designer that the provider was not supported, we found out that you can only use SqlMetal.exe from the command line. So we generated the dbml from this utility and added it to the project, this added an entry to define the connection string in the app.config.

Finally, we tested this by trying updates/inserts using LINQ which worked fine. The next stage is building the WPF and binding to the Exceed datagrid, as WPF does not provide a datagrid.... will keep you posted!!

Quotes

"Excellent service, at an affordable price. Thank you."
Sue Baxter (Director) - Internet Gardener

Latest Projects

Angel Wings web design Labarde web design Internet Gardener web design Stonesilver web design Build Investment Jewellery web design

Developer Certifications

MCPD logo

Partners

Comodo logo protx logo

Coding Standards

XHTML CSS

Agilis Software Limited | 2 Lynemouth Court, Arnold, Nottingham. NG5 8TY
Registered in England No. 5688723. VAT No. 886 4538 70
Tel: 07973 766989
Email: stephen@agilissoftware.co.uk