LINQ on Mobile Devices – Webcast Follow Up and Other Goodies

You Can Take it With You

Syndication

News

  • Don't miss the next Windows Mobile Webcast... Unit Testing for Mobile Devices: http://msevents.microsoft.com/CUI/WebCastEventDetails.aspx?EventID=1032382824&EventCategory=4&culture=en-US&CountryCode=US.

Thanks again to everyone who attended my LINQ on Mobile Devices Webcast today – If you missed it, the webcast is available for On-Demand viewing starting tomorrow (Thursday, 28-February-2008).

First let me apologize for the difficulty in showing the screenshots of the CLR Profiler output. But the good news is… the screenshots are visible here. J
As a reminder, these two screenshots show the overhead of having to load SQL Server Compact (SSC) tables into a DataSet to be able to query the table contents with LINQ as opposed to using LINQ to query directly against the database tables through a SqlCeResultSet.

Memory Statistics when Using a DataSet

Memory Statistics when Using a ResultSet

These shouldn't be a huge surprise, but they really do reinforce the cost of using DataSets on a mobile device. Notice that not only does the SqlCeResultSet version have a final heap size that is nearly 85% smaller than that of the DataSet version. But the SqlCeResultSet version incurs only a single Garbage Collection compared to 4 Garbage Collections for the DataSet version.

These differences in memory and GCs map to real differences in application performance, resource consumption and power usage. Keep in mind, that the NorthWind database that these examples use is only moderate in size by real-life standards. As data volumes grow, these differences can become much greater.

Custom Extension Method & Enumerator Performance

This chart shows how much we were able to improve the performance of querying against the SqlCeResultSet directly through the use of a very simple custom Where extension method along with the introduction of a smart custom enumerator.

Sample Downloads

And finally, here are the downloads for the various code samples shown during the webcast

  • First demo – Shows how the difference in LINQ-based method support affects the behavior of the LINQ language syntax
  • Second demo – Shows the time and resource cost of using a DataSet as compared to a SqlCeResultSet (goes with the first 2 screenshots)
  • Third demo – Shows the benefit of using a custom extension methods and enumerators to query the SSC database tables directly (goes with the above chart)

(VB Samples are available on this post)

Thanks again – if you have any questions, feel free to ask them here. I do my best to respond to as many as I can.

(View Webcast On-Demand)


Posted Feb 27 2008, 03:33 PM by jim-wilson

Comments

Bob wrote re: LINQ on Mobile Devices – Webcast Follow Up and Other Goodies
on 02-28-2008 3:47 AM
Would it possible to include VB version of your code? I know you may saw that it's easy to convert them, but stopping to convert them (sometimes not that easy for those who don;t know C#) breaks up the learning experience.
Jim Wilson wrote re: LINQ on Mobile Devices – Webcast Follow Up and Other Goodies
on 02-28-2008 7:05 AM
Bob;

Your point is well taken - converting between the two languages is easy only if the one doing the conversion knows both languages. :-)

In code like this where we're doing a lot with extension methods, lambda expressions (a variation on anonymous delegates), and other goodies, the concept of conversion being a simple mechanical process doesn't really hold anymore.

I'll get VB versions of demos 2 & 3 (demo 1 already is in VB) out later today.

Thank you,
- Jim
Jer wrote re: LINQ on Mobile Devices – Webcast Follow Up and Other Goodies
on 04-17-2008 2:14 PM
Do you have any examples of Select extensions, where they transform a SqlCeUpdatableRecord into a more complex object?

For example:
var orders = from order in resultSet
where (string)order["Ship Country"] == "UK"
select new Order { OrderID = order["Order ID"], ...}

In the select portion of the query, an Order object can be created but the code starts to bloat a little bit once you start initializing additional properties. Can that initialization be moved into an extension method so the query stays lean + clean?
Jim Wilson wrote re: LINQ on Mobile Devices – Webcast Follow Up and Other Goodies
on 04-18-2008 6:30 AM
Jer;

Good point...

I don't have any existing samples, but I'll get a couple together. Thanks for the great suggestion - I'll post 'em here as soon as I have 'em.

Thanks,
Jim
Jim Wilson wrote re: LINQ on Mobile Devices – Webcast Follow Up and Other Goodies
on 04-18-2008 12:40 PM
Jer;

I've posted some samples and discussion around the issue you've raised in the post I just put up: http://www.pluralsight.com/blogs/jimw/archive/2008/04/18/50753.aspx

Let me know how that info works for you.

Thanks again,
Jim
Jer wrote re: LINQ on Mobile Devices – Webcast Follow Up and Other Goodies
on 04-21-2008 9:03 AM
Hey Jim,

Thanks for the examples and the tip about caching the ordinals. Works out great :)

Thanks again,
Jer
Jim Wilson wrote re: LINQ on Mobile Devices – Webcast Follow Up and Other Goodies
on 04-21-2008 9:23 AM
Jer;

It's my pleasure - Glad I could help.

Thanks for the great post suggestion!

- Jim

Add a Comment

(required)  
(optional)
(required)  
Remember Me?