我在查看页面上收到错误消息:
无法将类型“System.Collections.Generic.List”隐式转换为“SchoolAdministrator.SchoolAdminProductionServices.SchoolTypeRef”
我想知道我是怎么得到这些错误的。我相信我做的一切都是正确的
控制器
[SchoolAuthorizeAttribute(AdminRoles = "ViewSchoolTypeRef")]
public ActionResult ViewSchoolType()
{
try
{
Guid SchoolTypeRefId = Request["SchoolTypeRefId"] != null ? new Guid(Request["SchoolTypeRefId"]) : Guid.Empty;
ViewBag.merchantTypeRef = SchoolAdministrator.Models.SchoolAdminProduction.SchoolTypeRef.LoadSchoolTypeRef(SchoolTypeRefId, string.Empty, string.Empty, string.Empty);
}
catch (Exception e)
{
Commons.ErrorHandling.ReportError("SchoolAdministrator.Controllers.SchoolController ViewSchoolType",e);
}
return View();
}
模型
public class SchoolTypeRef
{
/// <summary>
/// This function allows us to load the School types if parametrs are empty, else load a single user by their ID
/// </summary>
/// <param name="SchoolTypeRef">The merchant type ref id, unique ID</param>
/// <param name="name">name of the School type</param>
/// <param name="description">description of the School type</param>
/// <returns>List of all users or list of a single user</returns>
public static List<SchoolAdminProductionServices.SchoolTypeRef> LoadSchoolTypeRef(Guid SchoolTypeRef, string name, string description, string fdrSchoolTypeCode)
{
try
{
SchoolAdminProductionServices.SchoolAdminProductionServicesSoapClient client = new SchoolAdminProductionServices.SchoolAdminProductionServicesSoapClient();
return client.LoadSchoolTypeRef(SchoolTypeRef, name, description, fdrSchoolTypeCode).ToList<SchoolAdminProductionServices.SchoolTypeRef>();
}
catch (Exception e)
{
Commons.ErrorHandling.ReportError("SchoolTypeRef.LoadSchoolTypeRef()",e);
}
return new List<SchoolAdminProductionServices.SchoolTypeRef>();
}
}
查看这是 <% %> 之间发生错误的地方
<%SchoolAdministrator.DarkstarAdminProductionServices.SchoolTypeRefmerchantTypeRef =
ViewBag.SchoolTypeRef ??
new SchoolAdministrator.SchoolAdminProductionServices.SchoolTypeRef();%>
<table>
<tr>
<td colspan="2" class="tableHeader"> School Type Ref Details</td>
</tr>
tr>
td class="label"> Name:</td>
td class="content"><%=SchoolTypeRef.name%></td>
/tr>
tr>
td class="label"> Description:</td>
td class="content"><%=SchoolTypeRef.description%></td>
/tr>
tr>
td class="label"> FDR SchoolType Code:</td>
td class="content"><%=SchoolTypeRef.fdrSchoolTypeCode%></td>
/tr>
/table>