Linked Questions

2 votes
1 answer
736 views

What's wrong with SelectMany? [duplicate]

I've encountered an issue with the SelectMany expression that I just can't wrap my head around. Consider this: I have a collection of objects of this class class Tag { string DisplayText { get; ...
DanDan's user avatar
  • 1,227
0 votes
1 answer
616 views

How to select values which are inside list of list in C#? [duplicate]

I have a list of the object inside a list. I want a list of objects based on some condition. List<List<int>> lists = new List<List<int>> { new List<int> {1, 2, 3}, ...
Avadh Vashisth's user avatar
482 votes
18 answers
688k views

What is the syntax for an inner join in LINQ to SQL?

I'm writing a LINQ to SQL statement, and I'm after the standard syntax for a normal inner join with an ON clause in C#. How do you represent the following in LINQ to SQL: select DealerContact.* from ...
Glenn Slaven's user avatar
  • 33.9k
174 votes
9 answers
72k views

What is the use of Enumerable.Zip extension method in Linq?

What is the use of Enumerable.Zip extension method in Linq?
user634871's user avatar
  • 1,783
152 votes
4 answers
91k views

How to flatten nested objects with linq expression

I am trying to flatten nested objects like this: public class Book { public string Name { get; set; } public IList<Chapter> Chapters { get; set; } } public class Chapter { public ...
ab_732's user avatar
  • 3,789
74 votes
1 answer
29k views

Fetch vs FetchMany in NHibernate Linq provider

NHibernate eager loading can be done using Fetch and FetchMany, as described in NHibernate Linq Eager Fetching on Mike Hadlow's blog. What is the difference between these two methods and under what ...
Simon's user avatar
  • 1,499
21 votes
3 answers
34k views

How to query a nested list using a lambda expression

In my repository implementation I can run the following query using a lambda expression: public IList<User> GetUsersFromCountry(string) { return _UserRepository.Where(x => x.Country == "...
Flo's user avatar
  • 729
13 votes
1 answer
7k views

Select all unique combinations of a single list, with no repeats, using LINQ

I have a list of numbers, and I need to create every possible unique combination of the numbers in the list, without repeats, using a LINQ query. So, for example, if I have { 1, 2, 3 }, the ...
user avatar
5 votes
1 answer
19k views

C# linq Select objects in list looking inside another list of objects

I have a class like this: public class MailMessage { public string From {get; set; }; public string To {get; set; }; public ICollection<Attachment> Attachments { get; set; } } ...
Gauravsa's user avatar
  • 6,393
3 votes
3 answers
8k views

Get the specific element in nested list using lambda in c#

Good days, Lets say I have a static List<AClass> object (lets name it myStaticList) which contains an other list inside and that list contains an other list with CId and Name property. What I ...
Valermus's user avatar
7 votes
3 answers
4k views

Select and select many difference

I have read many sites/threads on select and select many in LINQ but still don't quite understand. Does select return one element in a collection and select many flatten a collection (eg List>())? ...
GurdeepS's user avatar
  • 66.3k
3 votes
3 answers
4k views

C# LINQ - Return a typed filtered list based on a child property that is inside another list

Given the Objects : class Parent { private int id; public int Id { get { return id; } set { id = value; } } private List<Child> childrenList; public ...
asd123ea's user avatar
  • 121
1 vote
2 answers
7k views

How to group by and order by a collection using linq? [closed]

I am doing it this way but it won't work (Do not compile), i need to GroupBy first then OrderBy. lstOrderItems.OrderBy(x => x.itemPrice).GroupBy(p => p.CatID);
NoviceToDotNet's user avatar
0 votes
2 answers
7k views

Unable to cast object of type '<SelectManyIterator> to type 'System.Collections.Generic.List

i need to select specific two columns from a list and load those values for two combo boxes. i tried to do this using LINQ and it is passing me an error " Unable to cast object of type ' to type '...
Didu's user avatar
  • 79
3 votes
4 answers
366 views

Simple LinQ question: convert [][] to []

I would like to get collection or list of Item objects, but I get array of arrays now. Item[][] s = employees.Select(e => e.Orders.Select(o => new Item(e.ID, o.ID)).ToArray()).ToArray(); Can ...
Maxim Polishchuk's user avatar

15 30 50 per page
1
2 3 4 5