在 ASP.NET Core-6 实体框架中,我使用通用存储库:
public interface IGenericRepository<T> where T : class
{
Task<T> GetByIdAsync(object id);
}
public class GenericRepository<T> : IGenericRepository<T> where T : class
{
private readonly ApplicationDbContext _context;
internal readonly DbSet<T> _table;
public GenericRepository(ApplicationDbContext context)
{
_context = context;
_table = context.Set<T>();
}
public virtual async Task<T> GetByIdAsync(object id)
{
return await _table.FindAsync(id);
}
}
Run Code Online (Sandbox Code Playgroud)
我收到这个警告:
此处“_table”不为空通用存储库中可能返回空引用
我该如何解决这个问题?
谢谢
我已在 Windows-10 本地系统上成功安装了 Nodejs。
当我执行:npm 版本时,我得到:
C:\WINDOWS\system32>npm version
{
npm: '8.5.3',
node: '16.14.0',
v8: '9.4.146.24-node.20',
uv: '1.43.0',
zlib: '1.2.11',
brotli: '1.0.9',
ares: '1.18.1',
modules: '93',
nghttp2: '1.45.1',
napi: '8',
llhttp: '6.0.4',
openssl: '1.1.1m+quic',
cldr: '40.0',
icu: '70.1',
tz: '2021a3',
unicode: '14.0',
ngtcp2: '0.1.0-DEV',
nghttp3: '0.1.0-DEV'
}
Run Code Online (Sandbox Code Playgroud)
然而,正如我所做的:
C:\WINDOWS\system32>npm install -g @angular/cli
我收到这个错误:
npm ERR! code ECONNRESET
npm ERR! syscall read
npm ERR! errno ECONNRESET
npm ERR! network request to https://registry.npmjs.org/ajv failed, reason: read ECONNRESET
npm ERR! network This is a …
Run Code Online (Sandbox Code Playgroud)