So I've been looking at LINQ a little bit more in the context of building compelling mobile line of business applications.
I found out in my previous article that LINQ to Datasets is implemented in the .Net Compact Framework 3.5, so I thought great, lets have a go. So after a a bit of a fight (and help from Jim Wilson), I was able to get a mobile application up and running.
So I built a simple example building a .Net Compact Framework 3.5 application targeting Windows Mobile 6. We're going to add a SQL Compact database to it, then display data from a table on a datagrid using LINQ to Datasets.
If you add an SDF database to your project, automatically Visual Studio will prompt you for wether you'd like to have Datasets created for you automatically.
In my case, I elected to say 'Yes', for a table name mobile_application_versions, so cutting to the chase here's all you need to know, this is the C# code for populating my datagrid -
using (mobappvesionds mn = new mobappvesionds()) { using (Mob_application_versionsTableAdapter tableAdapter = new Mob_application_versionsTableAdapter()) tableAdapter.Fill(mn.Mob_application_versions);
var query = from mob_application_versions in mn.Mob_application_versions //where 1 == 1 select mob_application_versions; dataGrid1.DataSource = query.CopyToDataTable(); }
You'll need to add a reference to System.Data.DataSetExtensions but that's about it. Here's the end result -
So, all good so far. However I then got thinking. The Datasets needs to get filled first and then LINQ queries the Datasets. So in the case of applying queries using LINQ to Datasets your filtering the Datasets not the underlying database. This is obviously very inefficient as your bringing the data all out of the database first into a Datasets then ignoring any indexes or query optimisation that SQL Compact/SQL does so well then just filtering the Dataset. So I'm pleased that I got LINQ to Datasets working however careful thought needs to be made to ensure that LINQ really is the right way for building mobile line of business.
Theme design by Jelle Druyts
Pick a theme: BlogXP calmBlue
My Virtual Earth Balloon Races www.racingballoon.com Richard JonesPowered By The Fridge Server