Asp.net mvc 3 存储库未正确实现接口
我得到的错误是 错误1“OCDSandbox.Models.OrganizationRepository”未实现 接口成员 'OCDSandbox.Models.IRepository.FindByOrgNbr()'C:\source temp\OCDSandbox\OCDSandbox\Models\OrganizationRepository.cs第9行 OrganizationRespository.CSAsp.net mvc 3 存储库未正确实现接口,asp.net-mvc-3,repository-pattern,Asp.net Mvc 3,Repository Pattern,我得到的错误是 错误1“OCDSandbox.Models.OrganizationRepository”未实现 接口成员 'OCDSandbox.Models.IRepository.FindByOrgNbr()'C:\source temp\OCDSandbox\OCDSandbox\Models\OrganizationRepository.cs第9行 OrganizationRespository.CS 使用系统; 使用System.Collections.Generic; 使用Syst
使用系统;
使用System.Collections.Generic;
使用System.Linq;
使用System.Web;
命名空间OCDSandbox.Models
{
公共类组织存储库:IRepository
{
私有GMS_Sandbox_testDataContext_dataContext;
公共组织存储库()
{
_dataContext=新的GMS_Sandbox_testDataContext();
}
公共IList ListAll()
{
var organizations=来自_dataContext.organizations中的o
选择o;
返回组织。ToList();
}
公共ICollection FindAll()
{
return_dataContext.Organizations.ToList();
}
公共ICollection FindByOrgNbr(字符串OrgNbr)
{
var organizations=\u dataContext.organizations.Where(p=>p.org\u nbr==OrgNbr.ToList();
返回组织;
}
}
}
IRepository.CS
使用系统;
使用System.Collections.Generic;
使用System.Linq;
使用System.Web;
命名空间OCDSandbox.Models
{
公共接口假定
{
//组织界面
IList ListAll();
ICollection FindAll();//返回只读列表
ICollection FindByOrgNbr();
}
}
非常感谢您的帮助。这是我第一次使用repo,然后我想在controller中测试FindByOrgNbr。提前谢谢 在FindByOrgNbr定义的接口中缺少一个参数
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace OCDSandbox.Models
{
public interface IRepository
{
// organization interface
IList ListAll();
ICollection FindAll(); //returns list read only
ICollection FindByOrgNbr(string OrgNbr);
}
}
在FindByOrgNbr的定义中,接口中缺少一个参数
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace OCDSandbox.Models
{
public interface IRepository
{
// organization interface
IList ListAll();
ICollection FindAll(); //returns list read only
ICollection FindByOrgNbr(string OrgNbr);
}
}
谢谢,因为接口有以下方法:
ICollection FindByOrgNbr()
并且您的类具有公共ICollection FindByOrgNbr(字符串OrgNbr)
接口似乎也需要OrgNbr参数。谢谢,因为接口有以下方法:
ICollection FindByOrgNbr()
并且您的类具有公共ICollection FindByOrgNbr(字符串OrgNbr)
界面似乎也需要OrgNbr参数。在
FindByOrgNbr()
的界面定义中缺少OrgNbr
参数
公共接口IRepository
{
//组织界面
IList ListAll();
ICollection FindAll();//返回只读列表
ICollection FindByOrgNbr(字符串OrgNbr);
}
在FindByOrgNbr()
的接口定义中缺少OrgNbr
参数
公共接口IRepository
{
//组织界面
IList ListAll();
ICollection FindAll();//返回只读列表
ICollection FindByOrgNbr(字符串OrgNbr);
}
FindByOrgNbr不需要参数。FindByOrgNbr不需要参数。wow应该仔细看看。谢谢现在它说“方法'FindByOrgNbr'没有重载需要0个参数。你需要用参数调用FindByOrgNbr方法。我在控制器中调用它。哇,应该仔细看看。谢谢!现在它说“方法'FindByOrgNbr'没有重载需要0个参数。你需要用参数调用FindByOrgNbr方法。我在控制器中调用它。”。