我正在使用一种通用方法,该方法采用一个逻辑模型和一个回购模型,以便我具有可重用的代码来更新显示顺序。
实际的EF呼叫工作正常,但是出现错误
未找到实体类型'EntityQueryable
。确保已将实体类型添加到模型中。
我正在使用的代码在这里
internal async Task<List<LogicModel>> UpdateDisplayOrderAsync<LogicModel, RepoModel>(List<GridItemAndSortOrderLogicModel> models) where RepoModel : TrainingBase
{
using (var context = GetDbContext())
{
var originals = context.Set<RepoModel>().Where(a => models.Select((b => b.Id)).Contains(a.Id));
var loopy = from o in originals
join m in models on o.Id equals m.Id
select new { o, m };
foreach (var loop in loopy)
{
loop.o.DisplayOrder = loop.m.DisplayOrder;
context.Entry(loop.o).CurrentValues.SetValues(loop.o);
context.Entry(loop.o).State = EntityState.Modified;
}
await context.SaveChangesAsync();
_logger.LogInformation($"->> Updated comptency display order");
var retVal = context.Entry(originals).Entity.Adapt<List<LogicModel>>();
return retVal;
}
}
此调用是从此处的此代码块进行的
public async Task<List<ReportCompetencyLogicModel>> UpdateCompetencyDisplayOrderAsync(List<GridItemAndSortOrderLogicModel> models) => await base.UpdateDisplayOrderAsync<ReportCompetencyLogicModel, RepositoryModel.ReportCompetency>(models);
出现错误的行是var retVal = context.Entry(originals).Entity.Adapt<List<LogicModel>>();
非常感谢您如何获得通过。