小编Jas*_*son的帖子

.NET CORE 2.0尝试激活时无法解析类型服务

我有一个IDataRepository.cs文件,其中包含一个接口及其实现,如下所示:

public interface IDataRepository<TEntity, U> where TEntity : class
{
    IEnumerable<TEntity> GetAll();
    TEntity Get(U id);
    TEntity GetByString(string stringValue);
    long Add(TEntity b);
    long Update(U id, TEntity b);
    long Delete(U id);
}
Run Code Online (Sandbox Code Playgroud)

我有另一个实现IDataRepository接口的类TokenManager.cs:

public class TokenManager : IDataRepository<Token, long>
{
    ApplicationContext ctx;
    public TokenManager(ApplicationContext c)
    {
        ctx = c;
    }

    //Get the Token Information by ID
    public Token Get(long id)
    {
        var token = ctx.Token.FirstOrDefault(b => b.TokenId == id);
        return token;
    }

    public IEnumerable<Token> GetAll()
    {
        var token = ctx.Token.ToList();
        return token; …
Run Code Online (Sandbox Code Playgroud)

.net-core asp.net-core asp.net-core-webapi

4
推荐指数
1
解决办法
2万
查看次数