我有一个这样的抽象类:
public abstract class Placement<T>
where T : IElement
{ }
我还有另一个继承它的类:
public class ResourcePlacement : Placement<Resource>
{ }
某处我有业务逻辑,可以将位置保存到数据库中:
public interface IPlacementManagement<T, TPlacement>
where T : IElement
where TPlacement : Placement<T>
{
void SavePlacement(TPlacement placement);
}
abstract class PlacementManagementImplBase<T, TPlacement> : IPlacementManagement<T, TPlacement>
where T : IElement
where TPlacement : Placement<T>
{
public virtual void SavePlacement(TPlacement placement)
{
// Implementation.
}
}
在客户端,我试图像这样保存它:
var placement = new ResourcePlacement();
// Do something with placement.
this.placementMangagement.SavePlacement(placement);
但是我收到以下错误:
the best overloaded method match for IPlacementManagement<TEntity, TPlacement>.SavePlacement(TPlacement) has some invalid arguments.
为什么会出现此错误?
如何在ResourcePlacement
方法中将SavePlacement
实例作为参数传递?