Sunday, December 23, 2007

LINQ to Compact SQL

CodeProject - Compact LINQ

untitled

"...

One of the challenges encountered by developers looking to get acquainted with LINQ to SQL, is how to use it with SQL Server Compact Edition (SSCE), version 3.5. We were told LINQ will work with SQL Server for now; with more providers on the way (possibly not until LINQ to Entities is released). However, if you try to drag some tables from a Compact Edition data connection onto a new LINQ to SQL designer canvas, you'll witness a nasty error dialog stating that the provider is not supported!

...

Figure 1: The dreaded "unsupported data provider" error in the LINQ to SQL designer.

More accurately, the SSCE provider is not supported by the LINQ to SQL designer. You can still use the command-line tool, SQLMetal, to generate your data entities, data access, and other ORM code. If you prefer command-line tools, you're all set. If you like the idea of a visual representation of your entities, there is still hope.

I recommend creating a batch file or PowerShell script to generate your file(s) via SQLMetal. This allows you the benefit of a quick execution when you inevitably need to re-generate your data access layer due to schema changes. I've included one for download as an example.

For our sample application, the command needed is fairly simple.

..."

This is a cool, fairly in-depth article (12 printed pages) on using LINQ to SQL as well as using SSCE (SQL Server Compact Edition) as the provider. That and I liked the logo... ;)

No comments: