我在下面提到的代码中遇到了问题。它给我一个论点。 IRepository
public interface IUserRepository
{
List GetAll(); // Error shows me here then i change this to List<User> GetAll(); but still getting the error.
}
存储库
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();
}
}
答案 0 :(得分:2)
你应该尝试:
public interface IUserRepository<T>
{
List<T> GetAll();
}
然后:
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();
}
}