score:0
var prodotti = contesto.prodotti.where(x => x.prodottovisibile ==
true).orderbydescending(x => x.prodottoid)
//define random variable
var random = new random();
int index = random.next(prodotti.count);
//this line should return 5 random records from the list
prodotti.orderby(x => rnd.next()).take(5);
Source: stackoverflow.com
Related Query
- MVC Linq .Random() wrong syntax
- MVC ASP.Net LINQ syntax to search for any or part of string
- Linq within ASP.NET MVC controller syntax
- Linq syntax error in ASP MVC controller method
- How can I use query syntax from Linq for return random records?
- im not able to apply my LINQ SYNTAX statement to my MVC view
- Linq Syntax - Selecting multiple columns
- Using LINQ extension method syntax on a MatchCollection
- Is there a C# LINQ syntax for the Queryable.SelectMany() method?
- LINQ - Query syntax vs method chains & lambda
- Random element of List<T> from LINQ SQL
- LINQ group by expression syntax
- LINQ syntax where string value is not null or empty
- Optimal LINQ query to get a random sub collection - Shuffle
- How does LINQ expression syntax work with Include() for eager loading
- .NET LINQ query syntax vs method chain
- How to get a Random Object using Linq
- left outer join in lambda/method syntax in Linq
- What's the equivalent VB.NET syntax for anonymous types in a LINQ statement?
- Linq syntax for OrderBy with custom Comparer<T>
- GroupBy with linq method syntax (not query syntax)
- LINQ Lambda vs Query Syntax Performance
- linq select a random row
- How to Convert LINQ Comprehension Query Syntax to Method Syntax using Lambda
- AsNoTracking using LINQ Query syntax instead of Method syntax
- Is there a LINQ syntax for the (T, int) overloads of Where and Select?
- Syntax to execute code block inside Linq query?
- Differences in LINQ syntax between VB.Net and C#
- Syntax for linq query to List<string>
- Linq Orderby random ThreadSafe for use in ASP.NET
More Query from same tag
- Entity Framework: Join Entities of Different Types and Order by Date
- Simple Linqpad Linq join statement, select all fields
- LinQ Data Row and Column collection C#
- how to Update the value if already exists in database, if not then insert new record?
- When does Entity framework Linq query Hits Sql Databse?
- ASP.Net WebAPI IIQueryable covert to POCO Objects
- How to search a text using entity framework after split?
- How to access anonymous type projected in Linq query in the next chained extension method?
- C# Linq Comparing List Values using multiple fields and return item which doesn't satisfy the condition
- Cross Apply Values (1, columnName) as (code, display) in LINQ
- how to insert the database multiple gridview choises
- Compare 2 Properties of equals object
- Using LINQ to compare on a string value
- The type arguments cannot be inferred from the query in linq c# query
- LINQ/DataTable query for repeats
- is operator always results to false in C#
- Read all nodes value in root with there attribute through linq
- C# query and comparing entries in a CSV file
- Microsoft CRM 4.0 LINQ - Getting attribute displaynames from CRM with LINQ
- Batch update specify column dynamically
- Linq to Entity | Pass table join to model
- web api return complex object not getting serialized
- How to select all from array1 which contains the id from array2?
- C#, How to check Hour and minute only from Datetime?
- Returning a LINQ database query from a Method
- Specification inside LINQ with EF 4.3
- How do I invoke an extension method using reflection?
- how to loop in xml (XElement) and get values od Inside Elements
- How to get top N elements of a list with LinQ?
- If statement in LINQ (If no value do something...)