У меня есть класс Attempt, который представляет попытку моей видеоигры.
Код: Выделить всё
class Attempt(int Id, string UserId, int score)
{
public int Id { get; set; } = Id;
public string UserId { get; set; } = UserId!;
public int score { get; set; } = score;
}
Код: Выделить всё
var list = new List();
list.Add(new Attempt(1, "Joe", 20));
list.Add(new Attempt(2, "Alan", 25));
list.Add(new Attempt(4, "Joe", 30));
list.Add(new Attempt(7, "Violet", 500));
list.Add(new Attempt(5, "Violet", 10));
list.Add(new Attempt(9, "Paul", 10));
list.Add(new Attempt(66, "Paul", 10));
var queryable = list.AsQueryable();
И я хочу сделать это без преобразования IQueryable в IEnumerable, чтобы нам никогда не приходилось получать весь список попыток из БД.
Вот несколько примеров использования:
Код: Выделить всё
// attempts to check
var attempt1 = new Attempt(4, "Joe", 30); // existent attempt - should return the existing attempts rank
var attempt3 = new Attempt(58, "Joel", 47); // non-existent attempt - should get the rank right after the attempt with the lowest score higher than itself
var attempt2 = new Attempt(57, "Jonathan", 30); // non-existent attempt with colliding score - should return the same rank as any existing attempt with the same score
Подробнее здесь: https://stackoverflow.com/questions/789 ... ore-in-que