score:17
Accepted answer
you can do it with a middle-step by selecting an anonymous type:
db.resource.select(x => new { x.resource_id, x.name }).asenumerable().select(x => tuple.create(x.resource_id, x.name)).tolist();
creating a tuple is not a supported operation in linq to entities, so you have to select an anonymous type, which would be an equivalent to:
select [resource].[resource_id], [resource].[name]
then move to linq to objects by asenumerable
and get your tuple.
score:2
you can create a list from db.resource
and use linq to collections to erase this limitation:
var list = db.resource.tolist().select(res => tuple.create(res.resource_id, res.name));
the tuple
class does have some constructors (up to 8 items), but the create()
helper method makes the creation more straightforward.
Source: stackoverflow.com
Related Query
- How can I extract a list of Tuple from a specific table with Entity Framework / LINQ?
- How can I extract data from a list of parent objects with children?
- How to get product row from each order of child table list using Entity Framework Core?
- How to use LINQ to retrieve a list from another entity with a specific number of items
- How can I get data from the Entity Framework if I only know the table name and the column name from which to get the data?
- How to select elements from a table that are present in a junction table with LINQ - Entity Framework
- How to select specific columns in one-to-one relationship table along with few direct columns in Entity Framework Fluent API
- how to get a list of item in object from another table using linq and entity framework in C#?
- How to filter specific columns from a child table Entity Framework
- Entity Framework retrieve data from table with foreign key
- How can i write SQL update query with where clause in Entity Framework in C#
- How can I use Entity Framework on an object graph past a depth of 2 with MySQL Connector / NET?
- How to include one specific row from another table with LINQ to Entities
- Why is Entity Framework .ToList() with .Include very slow and how can I speed it up?
- How get database table name with schema name from entity programmatically
- How to do paging in entity framework with two table in MVC
- How can I get data from a list with a where clause to another list?
- How can I query using Entity Framework with an alpha-numeric comparison?
- How can I return if an optional navigation property exists from an Entity Framework Query?
- How can i copy data table records of different field name based on mapping list evaluating condition on source data table?
- How can I obtain objects from list with C# LINQ using boolean conditions?
- most efficient Entity Framework Code First method of flattening / projecting parent entity with specific child
- How to return values from a LINQ query and display them in a table using C#, ASP.NET MVC and Entity Framework
- Entity Framework - only get specific columns specified dynamically from list
- How to reference a specific object from a list in a config file using .NET MVC with C#
- In Entity Framework Core, how can I query data on joined tables with a condition at DB level (not local LINQ)?
- How to make a list from multiple rows from inner join in Entity Framework Core?
- Can I limit how many levels the .include adds with LINQ and Entity Framework 5?
- How can I return a object with the sum of all objects from a list using Linq?
- How to loop through a child list of objects in Entity Framework 4.1 code first
More Query from same tag
- Is there a way to simplify many joins over multiple fields in ef core?
- Linq grouping get multiple properties
- Access each element in a list inside a where clause
- Iterating an XML document using XDocument only return 1 descendant
- Appending to Query if not null
- Parallel.ForEach freezes after some time
- Custom Inclusive TakeWhile(), is there a better way?
- Pass in Array to Select Case
- Use LINQ for arbitrary sorting
- LINQ Expression for remove duplicates
- LINQ Select multiple or statement return distinct
- Elegant way to combine multiple collections of elements?
- Handling the children of a parent-child relationship using Linq to XML
- Inconsistent LINQ Results comparing DataTables
- CsvHelper - Split output files
- How to use Linq-to-SQL without having to generate all the classes?
- Reduce a list into smaller lists of two using LINQ (Functional Programming)
- Fixed File to Object array with positions configured in xml
- How do I get the Nth largest element from a list with duplicates, using LINQ?
- Thread-safe Cached Enumerator - lock with yield
- converting foreach to LINQ while writing to Logger or Console
- Can we using Linq Union to combine two sessions in MVC?
- Entity Framework 6 context not retrieving navigation properties
- Comparing Integer Array in Linq Query
- How to sort XDocument elements by attribute numerically?
- LINQ - is SkipWhile broken?
- Formatting a column of List in C#
- MonoTouch & LINQ - Operation is not valid due to the current state of the object
- How do I access specific rows in my LINQ model?
- Use Linq to search through list