C# 带有lambda的模型的两个属性的Html扩展

C# 带有lambda的模型的两个属性的Html扩展,c#,asp.net,asp.net-mvc-4,lambda,C#,Asp.net,Asp.net Mvc 4,Lambda,我需要调用一个HTML助手,从模型中传递两个属性。问题是当我尝试以下方法时: @Html.BsDropDownFor(x => x.Type.Id, x => x.Type.Descripcion, (IEnumerable<TextValue>)ViewBag.ClaseB) @Html.BsDropDownFor(x=>x.Type.Id,x=>x.Type.description,(IEnumerable)ViewBag.ClaseB) header方法的定义

我需要调用一个HTML助手,从模型中传递两个属性。问题是当我尝试以下方法时:

 @Html.BsDropDownFor(x => x.Type.Id, x => x.Type.Descripcion, (IEnumerable<TextValue>)ViewBag.ClaseB)
@Html.BsDropDownFor(x=>x.Type.Id,x=>x.Type.description,(IEnumerable)ViewBag.ClaseB)
header方法的定义如下:

  public static MvcHtmlString BsDropDownFor<TModel>(this HtmlHelper<TModel> htmlHelper,
      Expression<Func<TModel, TProperty>> expressionValue,
      Expression<Func<TModel, TProperty>> expressionText,
      IEnumerable<TextValue> items)
public static MvcHtmlString BsDropDownFor(此HtmlHelper HtmlHelper,
表达式expressionValue,
表达式expressionText,
(可数项目)
如果我定义

BsDropDownFor<TModel,TProperty> 
BsDropDownFor
在两个参数中,doing应具有相同的属性

我应该如何定义接收两个属性的方法

更新日期:2015年3月3日

我的分机终于工作了

更改了我的签名

  public static MvcHtmlString BsDropDownFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper,
                                           Expression<Func<TModel, TProperty>> expression,
                                           string elementIdText,
                                           IEnumerable<TextValue> items)
public static MvcHtmlString BsDropDownFor(此HtmlHelper HtmlHelper,
表情表情,
字符串elementIdText,
(可数项目)
expressionText为其他扩展方法建立,并在视图上调用

@Html.BsDropDownFor(x => x.Type.Id, Html.ModelPropertyTagId( x => x.Type.Descripcion), (IEnumerable<TextValue>)ViewBag.ClaseB)
@Html.BsDropDownFor(x=>x.Type.Id,Html.ModelPropertyTagId(x=>x.Type.descrippcion),(IEnumerable)ViewBag.ClaseB)

关于

这两个属性似乎需要单独的类型参数:

public static MvcHtmlString BsDropDownFor<TModel, TValue, TText>(
       this HtmlHelper<TModel> htmlHelper,
       Expression<Func<TModel, TValue>> expressionValue,
       Expression<Func<TModel, TText>> expressionText,
       IEnumerable<TextValue> items)
{
   ...
}
public static MvcHtmlString BsDropDownFor(
这个HtmlHelper HtmlHelper,
表达式expressionValue,
表达式expressionText,
(可数项目)
{
...
}

我希望能找到@Html。。。(新[]{x=>x.Type.Id,x=>x.Type.Description},…其他参数),谢谢你JLRisheyou对了,重构后代码添加了两个类型参数和htmlproperty,谢谢JLRishe