Abp在linq中使用_xxxxRepository.GetAll()
方法,ef,第一次出现问题,代码非常简单,第一次没问题。
System.InvalidOperationException:变量' context'类型 ' Abp.EntityFrameworkCore.AbpDbContext'引用范围'',但是 它没有定义。
代码:
var query = from a in _docmentBorrowRepository.GetAll()
join c in _docmentRepository.GetAll() on a.DocmentId
equals c.Id
join b in _abpDictionaryRepository.GetAll() on
c.Type equals b.Id
select new DocmentBorrowListDto()
{
CreationTime = a.CreationTime,
Attr = c.Attr,
Attr_Name = c.Attr.ToString(),
Id = a.Id,
Location = c.Location,
Name = c.Name,
No = c.No,
Type = c.Type,
Type_Name = b.Title,
UserId = a.CreatorUserId,
Status = a.Status,
Des=a.Des
};
if (string.IsNullOrWhiteSpace(input.SearchKey) == false)
{
query = query.Where(ite => ite.Name.Contains(input.SearchKey)||ite.No.Contains(input.SearchKey));
}
if (input.Type.HasValue)
{
query = query.Where(ite => ite.Type == input.Type);
}
if (input.Attr.HasValue)
{
query = query.Where(ite => ite.Attr == input.Attr);
}
switch (input.BorrowType) {
case BorrowType.????:
query = query.Where(ite => ite.UserId == AbpSession.UserId.Value);
break;
case BorrowType.????:
query = query.Where(ite => ite.Status==-1||ite.Status==3);
break;
case BorrowType.?????:
query = query.Where(ite => ite.Status ==2);
break;
case BorrowType.????:
query = query.Where(ite => ite.Status == 1);
break;
}
var count = query.Count();
var ret = (await query.OrderByDescending(r => r.CreationTime).PageBy(input).ToListAsync()).MapTo<List<DocmentBorrowListDto>>();