I have a table with many records,
This table contains a chart, I would like to get the position of a single user:
Here is what I tried but it doesn't work:
var res = _context.Chart
.OrderByDescending(r => r.Score)
.SkipWhile(x => x.Username != username)
.Select((t, i) => new { idx = i })
This gives an error, I tried many combination but I can't get it to work.
Processing of the LINQ expression 'DbSet .OrderByDescending(r => r.Score) .SkipWhile(x => x.Username != __username_0)' by 'NavigationExpandingExpressionVisitor' failed. This may indicate either a bug or a limitation in EF Core.
Any idea of how I should do it? Thanks!
Update: The following code works!
_context.Chart
.AsEnumerable()
.OrderByDescending(r => r.Score)
.Select((t, i) => new { Index = i, t.Score, t.Username })
.FirstOrDefault(c => c.Username == username);
But I am worried about performance, do you think it can cause problems? thanks