Skip to content

Instantly share code, notes, and snippets.

@chaliy
Created March 3, 2010 16:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chaliy/320730 to your computer and use it in GitHub Desktop.
Save chaliy/320730 to your computer and use it in GitHub Desktop.
// following is analog of the o => o.ContextID == ContextId;
var recordType = typeof(NventstoreProduct);
var recordParam = Expression.Parameter(recordType, "o");
var recordContextIDProperty = Expression.Property(recordParam,
recordType.GetProperty("ContextID"));
var serviceType = typeof (Nventstore);
var thisContextIDProperty = Expression.Property(Expression.Constant(this, serviceType),
serviceType.GetProperty("ContextId"));
var thisContextIDPropertyConveterd = Expression.Convert(thisContextIDProperty, typeof (Guid?));
return Expression.Lambda<Func<NventstoreProduct, bool>>(Expression.Equal(recordContextIDProperty, thisContextIDPropertyConveterd), recordParam);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment