2012-01-19 33 views
0

我有这样如何通过两个参数来System.Func

public BuildColumn<TModel> TEST<TProperty>(
    Expression<Func<TModel, TProperty>> expression, 
    string DisplayName, 
    object HTMLAttributes, 
    Expression<Func<TModel, string, TProperty>> SpecialHTMLAttributes, 
    bool Show) {} 

的功能。如果你看一下第四个参数,它是一个Expression<Func<TModel,string,TProperty>>。我在这里要做的是传递一个lambda表达式和一个字符串值,也许是“abc”。但我无法弄清楚如何通过这些论点或如何使用它们。
有谁知道如何将2个参数传递给System.Func<>,或者有没有更好的选择?

+0

你能证明你想要做什么或想如何使用它?我有点不清楚。 – Jacob

回答

1

也许这就是你想要的参数类型:

Func<TModel, string, TProperty> 

或者表现形式:

Expression<Func<TModel, string, TProperty>> 

这将允许你通过类似这样的说法:

(model, str) => model.SomeCode(str)