文件夹结构揭示[错误?] CS0246:“类型或命名空间名称‘IAsyncRepository<>’”找不到”
RE:DotNet 6.0 和 VS Community 2022(64 位)- CurrentVersion 17.1.1
此代码会导致编译器错误 CS0246:
using GloboTicket.TicketManagement.Domain.Entities;
namespace GloboTicket.TicketManagement.Application.Contracts.Persistence
{
public interface IOrderRepository: IAsyncRepository<Order>
{
}
}
以下代码不会(请注意使用前缀“Persistence”来引用 IAsyncRepository):
using GloboTicket.TicketManagement.Domain.Entities;
namespace GloboTicket.TicketManagement.Application.Contracts.Persistence
{
public interface IOrderRepository: Persistence.IAsyncRepository<Order>
{
}
}
为什么有这个必要吗? IAsyncRepository 和 IOrderRepository 是同一文件夹中的兄弟姐妹 - 即同一命名空间中!
无需“持久性”即可使用引用。如果在基类型“IAsyncRepository”中删除了“where T : class”前缀:
namespace GloboTicket.TicketManagement.Application.Contracts.Persistence
{
public interface IAsyncRepository<T> where T : class
{
/...
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论