0
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!

Fer Andrei
  • 11
  • 1

1 Answers1

2

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.

wkl
  • 1,896
  • 2
  • 15
  • 26
  • Apparently, but why? OP code doesn't seem to be **calling** that function. – Ivan Stoev Jan 10 '17 at 11:50
  • @IvanStoev As I have understood it, the OP has posted a working version and is asking why it will not work when he applies the same query to e.g. a `List`. – wkl Jan 10 '17 at 11:57