[英]Using the generic type 'System.Collections.Generic.List<T>' requires 1 type arguments in IRepository
I have a problem in my code below mentioned.It askes me the 1 argument. 我在下面提到的代码中有一个问题,它向我提出了1参数。 IRepository
知识库
public interface IUserRepository
{
List GetAll(); // Error shows me here then i change this to List<User> GetAll(); but still getting the error.
}
Repository 资料库
public class UserRepository : IUserRepository
{
private IDbConnection _db = new SqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString);
public List<User> GetAll()
{
return this._db.Query<User>("SELECT * FROM Users").ToList();
}
}
You should try with: 您应该尝试:
public interface IUserRepository<T>
{
List<T> GetAll();
}
And then: 接着:
public class UserRepository : IUserRepository<User>
{
private IDbConnection _db = new SqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString);
public List<User> GetAll()
{
return this._db.Query<User>("SELECT * FROM Users").ToList();
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.