View ページに次のようなエラーが表示されます。
タイプ '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>