请帮助我更正此代码。在接口中使用通用方法
我在班上
public interface IGenericSaveRepository
{
void Save<TEntity>(int id, ICollection<TEntity> entities) where TEntity : class;
}
public class GenericSaveRepository<TEntity> where TEntity : class,IGenericSaveRepository
{
private IUnitofWork<TEntity> _unitofWork;
private NaijaSchoolsContext _context;
public GenericSaveRepository(NaijaSchoolsContext context)
{
_context = context;
_unitofWork = new UnitofWork<TEntity>(_context);
}
public void Save(int id, ICollection<TEntity> entities)
{
foreach (var entity1 in entities)
{
//entity.Insert(entity1);
_unitofWork.Entity.Insert(entity1);
}
}
}
public class RatingRepo : GenericRepository<Rating>
{
private IGenericSaveRepository gen;
private readonly NaijaSchoolsContext _context;
public RatingRepo(NaijaSchoolsContext context)
: base(context)
{
_context = context;
}
public void Save(School school,Rating rating)
{
List<Rating> ratings = new List<Rating>();
ratings.Add(rating);
gen = new GenericSaveRepository<Rating>(_context);
gen.Save(23, ratings);
}
}
此行gen = new GenericSaveRepository<Rating>(_context);
不允许我有指定为具体型别等级有编译器错误。
我该怎么做?
感谢您的帮助。
确实评级实施IGenericSaveRepository? – 2014-10-20 11:30:36
GenericRepository和GenericSaveRepository 之间是否有区别或者是否是拼写错误? 此外,评级的代码缺失,请proivde。 –
mindfxxxedCoder
2014-10-20 11:34:09
不,它不执行它@ Selman22 – Seun 2014-10-20 11:35:15