This function can only be invoked from LINQ to Entities

2.2k Views Asked by At
var quotes = (from q in db.Intrebaris 
    where q.id_materie == id_mat & q.id_tip_intrebare == tip_intr
    select q)
    .OrderBy(x =>SqlFunctions.Rand())
    .Take(10);

return quotes.ToList();

Do you have any idea why this happens? Thank a lot!

1

There are 1 best solutions below

2
On

It's because of the SqlFunctions.Rand(). MSDN says:

You cannot call this function directly. This function can only appear within a LINQ to Entities query. This function is translated to a corresponding function in the database.