score:2
A friend of mine just helped me out on this:
var q = db2.cp_users.SelectMany(
u => u.cp_groups.Select(
g => new { Username = u.name, Groupname = g.name }));
Works fine for me. Is there any way to do this in query syntax?
score:1
In query syntax:
from u in db2.cp_users
from g in u.cp_groups
select new { Username = u.name, GroupName = g.name }
Source: stackoverflow.com
Related Articles
- Linq code to select one item
- LINQ Source Code Available
- creating Linq to sqlite dbml from DbLinq source code
- Avoiding duplicate code in Linq Select method
- How to Select top (5) contributors group by Business type code in c# linq query
- source code for LINQ 101 samples
- How to write aggregate query in LINQ reusing part of the select code
- how to select data by linq in many-to-many relationship in First code Entity framework 5
- How to write C# LINQ code to select based on condition
- LINQ Select mutiply columns as data source for combobox C#
- c# Linq or code to extract groups from a single list of source data
- How to convert a string to C# code in the SELECT of C# LINQ
- How to use LINQ to select object with minimum or maximum property value
- Convert string[] to int[] in one line of code using LINQ
- Async await in linq select
- Select distinct using linq
- LINQ query to select top five
- Linq select objects in list where exists IN (A,B,C)
- Code equivalent to the 'let' keyword in chained LINQ extension method calls
- Select a Dictionary<T1, T2> with LINQ
- LINQ Select Distinct with Anonymous Types
- Select multiple records based on list of Id's with linq
- Select Multiple Fields from List in Linq
- How to select only the records with the highest date in LINQ
- LINQ Using Max() to select a single row
- Create a Tuple in a Linq Select
- LINQ Group By and select collection
- How to select values within a provided index range from a List using LINQ
- How to use Lambda in LINQ select statement
- Return list using select new in LINQ
- Combining two LINQ queries into one
- Rotate an array using LINQ syntax
- Linq splitting group if there is missing number
- Group list by month
- QueryExtender Linq Orderby using TimeSpan.Parse
- Anyone knows any Linq to XQuery implementation?
- How can I select from an included entity in LINQ and get a flat list similar to a SQL Join would give?
- How can I use linq to sort by multiple fields?
- Non-static method requires a target. cant find an answer that seems to work
- LINQ - Group Join + Where clause
- In C#, GroupBy a property which is a List
- Sum() Returns null in Entity Framework Query
- Comparing two datatables through Linq
- Linq Expression.Add error but (+) does work in F#
- How to display video from xml file?
- how to write a query with 2 equals on linq?
- Build pairs out of list - without repetition
- Handle a Dynamic Select With Dyanmic Linq
- filtering a DataTable using LINQ
- Invalid operation exception was unhandled