Я пытался найти информацию о фильтрации моих звонков в базу данных, чтобы переупорядочить данные из базы данных, и обнаружил, что пока нет способа отфильтровать .Inclunde
или .ThenInclude
.
Ниже я попробовал, есть ли способ сортировки коллекции?
var workout = await context.Workouts
//.Include(w => w.Segments.OrderByDescending(x => x.Id))
.Include(w => w.Segments)
.ThenInclude(s => s.Sets) //this gets the sets for the segment
.Include(w => w.Segments)
.ThenInclude(s => s.Exercise) //try intellisense didn't show exercise
.Include(w => w.BodyParts) //to delete from bodyparts column need to fix
.SingleOrDefaultAsync(w => w.Id == id);
.Include(w => w.Segments.OrderByDescending(x => x.Name)) //doesn't work
.ThenInclude(s => s.Sets.OrderByDescending(x => x.Name)) //doesn't work
Ниже код не может преобразовать заказ IEnumerable
в мой домен
var workoutSegments = workout.Segments.OrderByDescending(x => x.Name);
foreach( var segment in workout.Segments)
{
segment.Sets.OrderByDescending(x => x.Name).ToList();
}
return workoutSegments;
public class Workout
{
public int Id { get; set; }
public string UserId { get; set; }
public string Name { get; set; }
public ICollection<Segment> Segments { get; set; }
public Workout()
{
Segments = new Collection<Segment>();
}
}