Page 1 of 1

Getting Random Row via Linq

Posted: Tue 05 Nov 2013 13:41
by ucelenli
When I use the traditional Guid way for getting a random row from a table i write this;

Code: Select all

var randomUser = db.Users.OrderBy(x => Guid.NewGuid()).FirstOrDefault();
but I get this error. I am using Devart.Data.Postgresql.Entity 7.0.17.0

Code: Select all

The EDM function 'Edm.NewGuid' is not supported by current.
I know I can use "ToList()" but I don't want to convert huge tables into lists for a random row. When will devart support this?

Re: Getting Random Row via Linq

Posted: Fri 08 Nov 2013 17:50
by Shalex
ucelenli wrote:The EDM function 'Edm.NewGuid' is not supported by current.
We will investigate the possibility of supporting the Edm.NewGuid function in dotConnect for PostgreSQL.

As a workaround, please use Devart.Data.PostgreSql.Entity.PgSqlFunctions.Random() for getting a random row from a table.

Re: Getting Random Row via Linq

Posted: Wed 13 Nov 2013 13:05
by Shalex
  • The Entity SQL canonical function NewGuid is supported
  • The config.QueryOptions.NewGuidGenerationMethod configuration option (by default SQL expression is used) is added to provide the possibility to set a way to generate new Guid
We will notify you when the corresponding build of dotConnect for PostgreSQL is available for download.

Re: Getting Random Row via Linq

Posted: Thu 14 Nov 2013 13:16
by Shalex
New build of dotConnect for PostgreSQL 7.1.36 is available for download!
It can be downloaded from http://www.devart.com/dotconnect/postgr ... nload.html (trial version) or from Registered Users' Area (for users with active subscription only).
For more information, please refer to http://forums.devart.com/viewtopic.php?f=3&t=28332.