我有一个 ViewModel 为:
public class ApplicationContentViewModel
{
public BPMSPARS.Models.MySql.application application {get; set;}
public BPMSPARS.Models.MySql.content content { get; set; }
public BPMSPARS.Models.MySql.app_delegation app_delegation { get; set; }
}
另一方面,我想在视图中创建一个列表:
@foreach (var item in Model)
{
i++;
<tr>
<td>@i</td>
<th>
@item.content.CON_VALUE
//where CATEGORY="TASK"
</th>
<th>
@item.content.CON_VALUE
//where CATEGORY="PRO_TITLE"
</th>
<th>@item.application.APP_CREATE_DATE</th>
<th>@User.Identity.Name.Split('-')[0]</th>
</tr>
}
事实上,我想在两列中以不同的条件显示一个字段( @item.content.CON_VALUE)
。
首先,我使用这个查询,但它不能返回第一个@item.content.CON_VALUE
,我不能为一个字段应用两个条件(在两列中)。
public ActionResult ProcessList()
{
var db1 = new wf_workflowEntities();
ApplicationContentViewModel APVM = new ApplicationContentViewModel();
var ViewModel = (from APP in db1.application
join app_del in db1.app_delegation on APP.APP_UID equals app_del.APP_UID
join Con in db1.content on APP.PRO_UID equals Con.CON_ID
where Con.CON_ID == APP.PRO_UID && app_del.APP_UID == APP.APP_UID && Con.CON_CATEGORY == "PRO_TITLE"
select new ApplicationContentViewModel
{
app_delegation = app_del,
application = APP,
content = Con,
}).AsEnumerable();
return View(ViewModel);
}
你知道一个合适的解决方案吗?