jeudi 4 février 2016

5 rows Selected randomly from the list using GUID

How to get Items of randomly selected using GUID? I tried it with the following method but do not sorted?

var Query1 = (from _factor in db.tblFactors orderby Guid.NewGuid() select _factor)
     .Take(5);
var Query2 = (db.tblFactors
    .Select(x => new { x.ID, x.Cost, x.UserID, fldOrder = Guid.NewGuid() })
        .OrderBy(x => x.fldOrder))
        .Take(5);

Of course the problem here is two:

-One is that why my code is not working

-Second, does this method for random selection using the GUID is true or not




Aucun commentaire:

Enregistrer un commentaire