Skip to content

Instantly share code, notes, and snippets.

@enisn
Last active May 5, 2020 12:30
Show Gist options
  • Save enisn/464ec2df57ae0bca93aca760d8c12d88 to your computer and use it in GitHub Desktop.
Save enisn/464ec2df57ae0bca93aca760d8c12d88 to your computer and use it in GitHub Desktop.
Challenge #1 - Expression - Manual
// x =>
var parameter = Expression.Parameter(typeof(Product), "x");
// x => x.Code
var property = Expression.Property(parameter, "Code");
// x.Code == filter.Code
var comparison = Expression.Equal(property, Expression.Constant(filter.Code));
var lambda = Expression.Lambda<Func<Product, bool>>(comparison, parameter);
var query = db.Products.Where(comparison);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment