我具有以下实体
public class Tag
{
public int Id { get; set; }
public string Description { get; set; }
public virtual ICollection<Image> Images { get; set; }
}
public class Image
{
public int Id { get; set; }
public DateTime Created { get; set; }
public virtual ICollection<Tag> Tags { get; set; }
}
我想返回一个Tag实体,其中包括按页面索引和图像项目列表数量排序
public Tag GetPaged(int tagId, int pageIndex, int itemsPerPage)
{
return dbSet
.Where(p => p.Id == tagId)
.Include(p => p.Images
.OrderByDescending(i => i.Created)
.Skip((pageIndex - 1) * itemsPerPage)
.Take(itemsPerPage))
.FirstOrDefault();
}
但是我有以下例外