你会如何翻译以下通用lambda函数为lambda表达式子查询:如何生产使用非通用拉姆达
context.AssociateWith<Product>(p => p.Regions.Where(r => r.Country == 'Canada')
我想没有任何<T>
或直接调用创建一个完整的lambda表达式。喜欢的东西:
void AddFilter(ITable table, MetaDataMember relation)
{
var tableParam = Expression.Parameter(table.ElementType, "e");
var prop = Expression.Property(tableParam, relation.Name);
var func = typeof(Func<,>).MakeGenericType(table.ElementType, relation.type)
var exp = Expression.Lambda(func, prop, tableParam);
}
这将产生e.Regions
......但我无法获得Where
部分从那里......
我更关注将使用非键入参数的东西。我会更精确地提出我的问题。 Thanx tho! – Mathlec 2009-09-29 00:32:02