Sterling Isolated Storage Database with LINQ for Silverlight and Windows Phone 7


Sterling is a lightweight object-oriented database implementation for Silverlight and Windows Phone 7 that works with your existing class structures. Sterling supports full LINQ to Object queries over keys and indexes for fast retrieval of information from large data sets.
The goal behind Sterling is to keep it:

  • Non-intrusive. You shouldn’t have to change your classes just to persist them.
  • Lightweight. As of this writing, the DLL for Sterling is under 70 Kb. No one needs to bloat their project for something as simple as persisting data.
  • Flexible. While the core is light, Sterling is designed to handle any serialization task and make it ultra-easy to query databases using LINQ-to-Objects.
  • Portable. Sterling is designed to run on both Silverlight 4.0 and the Windows Phone 7.



Sample App:


.NET 4.0 LINQ Operator – Zip

.NET 4.0 includes the new extension method Zip with the Enumerable, ParallelEnumerable, and Queryable classes. Zip allows to merge two sequences. Other LINQ operators that merge two sequences are Union, Intersect, Join, and GroupJoin. These operators have been available since .NET 3.5.

Zip that is available with .NET 4 and can be compared to the Join operator. Instead of the keys that are used Zip just uses the order of the elements to combine elements from two sequences. Zip creates one element from two elements taken from two input sequences. How the elements are merged depends on a result selector function, and the elements can be of different types. This makes the declaration of the Zip method simpler.

public static IEnumerable<TResult> Zip<TFirst, TSecond, TResult>(
    this IEnumerable<TFirst> first,
    IEnumerable<TSecond> second,
    Func<TFirst, TSecond, TResult> resultSelector)

With Zip it’s for example possible to sum two the elements of two integer sequences by passing the Lambda expression (first, second) => first + second to the result selector. This creates the result values 8, 15, 22, 26 in the following code snippet.

int[] one = { 3, 7, 11, 14 };
int[] two = { 5, 8, 11, 12 };

var result1 = one.Zip(two, (first, second) => first + second);

Of course it’s possible to do anything in the selector method. The next code snippet returns the lower value of the two collections – 3, 7, 11, 12. You can also combine sequences of different types and return another type. That all just depends on the selector method.


Lucene tutorial is a open source text search engine library, ported from Lucene Java project.
Simone Chiaretta has publised a post series to learn more.

You man also interested in my other posts:

LINQ: Building an IQueryable provider series


LINQ: Building an IQueryable provider series

Here’s a list of all the posts in the building an IQueryable provider series.  If you want to get the latest and greatest source code just follow that last link.  If you want to discover how to build your own IQueryable provider read from the beginning.  It is sort of like a tutorial.

Part I – Reusable IQueryable base classes
Part II – Where and reusable Expression tree visitor
Part II – Local variable references
Part IV – Select
Part V – Improved Column binding
Part VI – Nested queries
Part VII – Join and SelectMany
Part VIII – OrderBy
Part IX – Removing redundant subqueries
Part X – GroupBy and Aggregates
Part XI – More of everything
Part XII – Relationships and the IQ Toolkit
Part XIII – Updates and Batch Processing
Part XIV – Mapping and Providers
Part XV – Transactions, Sessions and Factories
Part XVI – Performance and Caching

The source code found in this series is also available at CodePlex.

The Wayward WebLog : LINQ: Building an IQueryable provider series

LINQ to FQL (Facebook Query Language)


LINQ to FQL is an open source project, sources, binaries and samples can be found at CodePlex. This library extends the Facebook Developer Toolkit.


This library enables developers to use LINQ (.NET Language-Integrated Query) with Facebook instead of string based FQL queries. The main benefits for using this library are:

  • Type safety: queries are now typed and their syntax is verified during compilation.
  • Auto-complete now function when composing queries in Visual Studio.
  • Using Facebook / anonymous objects for query results.

Example: this following sample code retrieves the names and pictures of all of your friends.

var db = new FacebookDataContext();
var friendIDs = from friend in db.friend_info where friend.uid1 == db.uid select friend.uid2;
var friendDetails = from user in db.user where friendIDs.Contains(user.uid) select new { Name =, Picture = user.pic_small };

Via CodeProject: LINQ to FQL (Facebook Query Language). Free source code and programming help

LINQ “Any” Keyword to check for existence of an element/attribute

One of the things you must do when writing a LINQ to Xml query definition is check for the existence of nonrequired elements and attributes before using them. For instance, a client application displays an image of the book in the ListBox control. The source URL of the image is grabbed from the SmallImage element’s URL element. If the SmallImage element does not exist, which is certainly a possibility if there is no image on record, the LINQ query definition must account for this.

For example,



Before grabbing a value, you can perform a simple check to make sure the element exists; you do this by checking the Elements collection’s Any method. The Any method returns a Boolean value that indicates whether the collection contains elements. If the element exists, you can grab the value of the element. If the element does not exist you can set alternatives. The following shows the logic that checks for the existence of the image’s URL; if it is found it grabs the value and sets it to the imageSource variable.

let imageSource = (book.Elements(ns + "SmallImage").Any()
    ? book.Element(ns + "SmallImage").Element(ns + "URL").Value
    : string.Empty)
p.s. for more on the usage of the keyword let, take a look at