【发布时间】:2015-07-21 18:51:13
【问题描述】:
我刚刚在这个控制器中将我的模型链接到我的视图模型 - 这似乎有效。代码如下:
public ActionResult TechSearchKnowledgebase([Optional]Guid? createdById, [Optional]Guid? categoryId, [Optional]Guid? typeId)
{
var model = db.Knowledgebases.AsQueryable();
if (createdById != Guid.Empty)
{
model = model.Where(k => k.CreatedById == createdById);
ViewBag.CreatedBy = db.Users.Where(c => c.UserId == createdById).First().FullName;
}
if (categoryId != Guid.Empty)
{
model = model.Where(k => k.CategoryId == categoryId);
ViewBag.Category = db.Categories.Where(c => c.CategoryId == categoryId).First().CategoryName;
}
if (typeId != Guid.Empty)
{
model = model.Where(k => k.TypeId == typeId);
ViewBag.Category = db.Roles.Where(c => c.RoleID == typeId).First().RoleDescription;
}
model=model.OrderBy(k => k.CreatedDate);
List<KnowledgebaseResult> knowledgebaseResults = Mapper.Map<List<KnowledgebaseResult>>(model.ToList());
return View("TechKnowledgebaseList", knowledgebaseResults);
}
我的代码有问题:
如果我加载它,我会收到此错误:
参数字典包含无效的参数条目 方法“System.Web.Mvc.ActionResult”的“categoryId” TechSearchKnowledgebase(System.Nullable
1[System.Guid], System.Nullable1[System.Guid], System.Nullable1[System.Guid])' in 'HelpDesk.WebUI.Controllers.KnowledgebaseController'. The dictionary contains a value of type 'System.Reflection.Missing', but the parameter requires a value of type 'System.Nullable1[System.Guid]'。 参数名称:参数
【问题讨论】:
标签: c# visual-studio mvvm controller