我试图从我的控制器调用我的模型,但得到错误.错误已开启
new UserModels(id, searchcriteria);
并指出
UserModels does not contain a constructor that takes 2 arguments.
有任何想法吗?
控制器/行动:
public ActionResult ID(string id)
{
ViewBag.Message = "Customer Information";
string searchcriteria = "userid";
UserModels model = new UserModels(id, searchcriteria);
return View();
}
Run Code Online (Sandbox Code Playgroud)
模型:
public class UserModels
{
public UserData user { get; set; }
public string firstname { get; set; }
public string lastname { get; set; }
public string searchvalue {get; set; }
public string searchcriteria { get; set; }
public List<UserData> UserModel(string id, string searchcriteria)
{
SSO_Methods sso = new SSO_Methods();
List<UserData> userObject = sso.GetUserObject(id, searchcriteria);
return userObject;
}
}
Run Code Online (Sandbox Code Playgroud)
c#中的构造函数不能返回任何内容.
你的代码需要
public UserModels(string id, string searchcriteria)
{
// your code here
}
Run Code Online (Sandbox Code Playgroud)
然后,如果您想要返回列表,请添加
public List<UserData> GetUserModels(string id, string searchcriteria)
{
SSO_Methods sso = new SSO_Methods();
List<UserData> userObject = sso.GetUserObject(id, searchcriteria);
return userObject;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
57 次 |
| 最近记录: |