MSDN Archive Home
Help and FAQs
Expression Tree Serialization
All Resource Updates
Change History (all pages)
Resource Page Description
The sample includes these components:
# *An Expression Tree serialization API*: A general purpose XML serialization of Expression Trees. This should work over any expression tree – though there are inevitably bugs. The serialization format is fairly crude, but has been expressive enough to support the variety of expression trees I’ve tried throwing at it.
# *A wrapper for serializing/deserializing LINQ to SQL queries*: A wrapper around the expression serializer allows serializing LINQ to SQL queries and de-serializing into a query against a given DataContext.
# *A WCF service which accepts serialized query expression trees and executes against a back-end LINQ to SQL*: To enable querying across tiers, a WCF service exposes service methods which execute serialized queries. The service implementation deserializes the queries against its LINQ to SQL connection.
# *An IQueryable implementation wrapping the client side of the WCF service*: The client-side calling syntax is simplified by providing an IQueryable implementation. This implementation, RemoteTable, executes queries by serializing the query expression tree and calling the appropriate service. The object model that the service user is able to query against is imported by the WCF service reference per the DataContracts on the LINQ to SQL mapping on the server side.
**Delete the following note before publishing **
This resource page is currently in setup mode and only available to coordinators and developers. Once you have finished setting up your resource page you can publish it to make it available to all MSDN Code Gallery visitors.
To get your Resource Page ready to publish, you should do the following:
Make any changes to the details of your resource page
Here you can enable or disable functions of your resource page. You might want to turn on the Issue Tracker to allow users to provide feedback on your resource, or if you have a resource that does not involve a code sample, you may want to turn off the Releases tab.
Make sure your resource page description is detailed enough to let people search for your resource.
Add your code sample or other resources to the resource page
If you’re uploading code, go to the Releases tab and create a new release to house your code. Creating a release allows you to have the license properly displayed when people download your code, as well as provides a download count.
Edit your Wiki page to attach any resources you may have that are not source code.
If you want to let someone see your resource page before it is published, go to the People tab and add them to your resource page
This will let you add other team members who may be contributing to your resource, or just show it off and get feedback from someone you trust.
Tag your resource page with descriptive tags to make it easier for people to find your resources when browsing the gallery.
Publish your resource page so it becomes visible to everyone!
Additional information on starting a new resource page is available here:
Resource Page Startup Guide
Nov 20 2008 at 8:57 PM
, version 1
Mar 15 2011 at 10:14 PM
There are some performance issues with this library. I've seen serialized expressions reach 60mb for a not terribly complex expression - such where x in (1,2,3,4,5,5,6....) and take quite a while to generate.
Even simpler expressions turn out very verbose.
If you're not going across the wire, it may not be a problem, but you should do some perf. analysis before you adopt to your own system.
Oct 12 2011 at 2:42 PM
Would the JsonSerializer work against an expression tree or is there a technical limitation to it?
Aug 14 2012 at 3:20 PM
InterLinq (http://interlinq.codeplex.com/) also has an implementation for expression serialization. Below is an example of using InterLinq to serialize and deserialize an expression tree.
public class UnitTest1 : IObjectSource
public void TestMethod1()
var testInt = 3;
Expression<Func<int, bool>> expr = num => num == testInt || num == 5;
var meth = expr.Compile();
var serializedExpr = expr.MakeSerializable();
var handler = new ObjectQueryHandler(this);
var converter = new SerializableExpressionConverter(serializedExpr, handler);
var deserializedExpr = converter.Visit(serializedExpr);
expr = deserializedExpr as Expression<Func<int, bool>>;
meth = expr.Compile();
public IEnumerable<T> GetObjects<T>()
// never called for this test
throw new NotImplementedException();
Sign in to add a comment
Thu Nov 20 2008 at 8:00 AM
More Tags ...
Visual Studio 2005
Visual Studio 2008
Visual Studio 2010
Manage Your Profile
MSDN Flash Newsletter
© 2008 Microsoft Corporation. All rights reserved.