-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add EF.Functions.Random() #16141
Comments
@max619, According to the message @yukozh wrote when that issue was closed, Pomelo provider would need to support translating some method to the rand() function on the server. I am not if this is supported but it would be better to ask in Pomelo.EntityFrameworkCore.MySql. |
@maumar I had a note in triage to ask you to find out if we had a spec test for this. However, based on PomeloFoundation/Pomelo.EntityFrameworkCore.MySql#265, it seems that |
Talked to @maumar offline. We don't have spec test for this. in principle, it is probably not a good candidate for a spec test given that:
That said, if we think of spec tests as a check list of high level functionality a provider should supply, then it seems ok to have an abstract test and let providers override it. Let's decide what to do with this on next triage. |
Why not add the Method In my mind this should be included there are many use-cases you need this. |
@timia2109 Agreed. I had the same thought in bricelam/EFCore.SqliteEx#10 |
Re-opening to track adding adding a standard Random function for providers to implement. Nearly all of them return a floating-point value between 0 and 1, so I think we should use that as the spec.
|
Opened npgsql/efcore.pg#1457 to track on the Npgsql side. |
Note that mapping to RAND for SQL Server will not work for ordering, as RAND() is evaluated only once per query, not on each row (unless RAND() appears in the SELECT clause). There are only a few TSQL functions are evaluated for each row if they don't take an argument from the row. You could use something rand(checksum(newid())) generate a random(ish?) value that can be used for sorting. |
Is it possible to retrive random sequence of entities using mysql
rnd()
function and how to do it?Obviously
OrderBy(x=>Guid.NewGuid())
is not working as referenced hereThe text was updated successfully, but these errors were encountered: