使用存储库模式时出错
Error while using repository pattern
我正在使用存储库模式并收到此错误
Severity Code Description Project File Line Suppression State
Error CS0311 The type 'Pricehunter.DataLayer.Data.Category' cannot be used as type parameter 'TEntity' in the generic type or method 'IRepository'. There is no implicit reference conversion from 'Pricehunter.DataLayer.Data.Category' to 'Repository.Pattern.Infrastructure.IObjectState'. Pricehunter.DataLayer E:\Development\PriceHunter\Pricehunter.DataLayer\Interfaces\ICategoryRepository.cs 12 Active
在实施这一行时 code.I 查看了一些问题但无法解决问题。
public interface ICategoryRepository : IRepository<Category>
{
Category GetCategory();
}
仅当实体 classes 或 POCO classes 继承自 ENTITY class 时,IObjectState 才可用。这样你就可以修改状态了。
public partial class myPocoClass : Entity
{
}
public abstract class Entity : IObjectState
{
[NotMapped]
public ObjectState ObjectState { get; set; }
}
我正在使用存储库模式并收到此错误
Severity Code Description Project File Line Suppression State Error CS0311 The type 'Pricehunter.DataLayer.Data.Category' cannot be used as type parameter 'TEntity' in the generic type or method 'IRepository'. There is no implicit reference conversion from 'Pricehunter.DataLayer.Data.Category' to 'Repository.Pattern.Infrastructure.IObjectState'. Pricehunter.DataLayer E:\Development\PriceHunter\Pricehunter.DataLayer\Interfaces\ICategoryRepository.cs 12 Active
在实施这一行时 code.I 查看了一些问题但无法解决问题。
public interface ICategoryRepository : IRepository<Category>
{
Category GetCategory();
}
仅当实体 classes 或 POCO classes 继承自 ENTITY class 时,IObjectState 才可用。这样你就可以修改状态了。
public partial class myPocoClass : Entity
{
}
public abstract class Entity : IObjectState
{
[NotMapped]
public ObjectState ObjectState { get; set; }
}