score:3
Accepted answer
This is not possible with LINQ expressions. You could use the following:
Quantities = numbers.Select((s, index) => new SelectListItem
{
Value = index.ToString(),
Text = s.ToString()
);
score:0
You can use the method syntax instead of the query syntax:
var quantities = numbers.Select((x,i) => {...});
Source: stackoverflow.com
Related Articles
- How to get the index of int array when using linq query
- Linq sub query when using a repository pattern with EF code first
- How can I check the number of calls to the database in LINQ query when using .NET Core and Code First?
- Join Two Array based on Index and Index Value using Linq Query Expression Syntax
- How to avoid Query Plan re-compilation when using IEnumerable.Contains in Entity Framework LINQ queries?
- Take the first five elements and the last five elements from an array by one query using LINQ
- Getting a collection of index values using a LINQ query
- Using C# Linq to return first index of null/empty occurrence in an array
- Using LINQ To Query Int Ids From An Array
- Why is this LINQ query not executed when using foreach?
- Entity Framework Linq Query to List - Error when using contains: Only primitive types, enumeration types and entity types are supported
- How to reuse a linq expression for 'Where' when using multiple source tables
- Linq query using list or array of ids
- Avoiding code repetition when using LINQ
- Get array index values of the top 1000 largest entries inside an array using LINQ
- How can I write the following code more elegantly using LINQ query syntax?
- How to construct IQueryable query using Linq when I just need count without reading all documents in Document-Db database?
- C# Using LINQ Query compare the records with result of process array
- How to use expressions to build a LINQ query dynamically when using an interface to get the column name?
- LINQ query returns old results when source list is re-initialized
- Check if List is not null when using "contains" in LINQ query else select all records
- LINQ query does not compile when using double, float, or decimal instead of int
- EXTREMELY Poor LINQ Query Performance When Using Skip/Take for Paging
- Error when defining a query param type List<int> inline using Linq
- Monotouch blows up on LINQ query when using device builds
- Error when using "Include" method on a LINQ Query
- Exception raised when using a Linq query with Entity Framework
- Get Index of a String Array after Split using LINQ
- How do I trace a linq query when using PredicateBuilder/AsExpandable?
- Using LINQ query result for data source for GridControl c#
- Excel to SQL, C# libraries
- Combine datatables with specific conditions
- Indexes for LINQ queries
- Use IEnumerable.Sum to subtract in LINQ
- C# - Filling List with LINQ from another List<>
- C# Find best matching element / Simplify query to List
- How do I use "in" where clause in LINQ when retrieving records/entities in Microsoft CRM?
- How to select all objects that have a property value in list of values?
- Why is it better to use data structure in Entity Framework
- How to update an item in a List using LINQ
- IEnumerable with Prev/Next
- entity framework - does this do a dirty read?
- What's the most efficient way to get only the final row of a SQL table using EF4?
- Check if list1 contents matches list2 contents
- Multiple LINQ query error
- Find specific value from list in c# MVC
- Get a list of entities by list of guids
- Use Linq to SQL to create unique list of numbers by merging two integer fields
- Understanding lazy loading optimization in C#
- Cannot compare elements of type 'System.Collections.Generic.ICollection`1 Only primitive types, enumeration types and entity types are supported