简体   繁体   English

使用通用类型&#39;System.Collections.Generic.List <T> &#39;在IRepository中需要1个类型参数

[英]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.

相关问题 使用泛型类型'System.Collections.Generic.List <T>'需要1个类型参数 - Using the generic type 'System.Collections.Generic.List<T>' requires 1 type arguments System.Collections.Generic.List <T> 需要&#39;1&#39;类型参数 - System.Collections.Generic.List<T> requires '1' type arguments 使用泛型类型'System.Collections.Generic.List <T>'需要'1'类型参数 - Using the generic type 'System.Collections.Generic.List<T>' requires '1' type arguments 使用泛型类型&#39;System.Collections.Generic.List <T> &#39;需要1个类型的参数 - Using the generic type 'System.Collections.Generic.List<T>' requires 1 type arguments 使用通用类型System.Collections.Generic.List <T> 需要1个类型参数 - Using the generic type System.Collections.Generic.List<T> requires 1 type arguments 错误使用泛型类型&#39;System.Collections.Generic.List&#39;需要&#39;1&#39;类型参数 - Error Using the generic type 'System.Collections.Generic.List' requires '1' type arguments 使用通用类型&#39;System.Collections.Generic.List&#39;需要&#39;1&#39;类型参数 - Using the generic type 'System.Collections.Generic.List' requires '1' type argument(s) 字典需要System.Collections.Generic.List类型的模型项 - Dictionary requires a model item of type System.Collections.Generic.List 键入“对象{System.Collections.Generic.List <T> }“ VS” System.Collections.Generic.List <T> ” - Type “object {System.Collections.Generic.List<T>}” VS “System.Collections.Generic.List<T>” 无法隐式转换类型&#39;System.Collections.Generic.list <fooClass> &#39;到&#39;System.Collections.Generic.List <T> - Cannot Implicitly convert type 'System.Collections.Generic.list<fooClass>' to 'System.Collections.Generic.List<T>
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM