All Questions
Tagged with linq ienumerable
995
questions
-1
votes
2
answers
91
views
How to find IEnumerable<T>.ToList() method by explicitly specifying type of parameters and then call it with a custom parameter type?
Let's say we have the following code (highly simplified modification of my own code):
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
namespace ...
0
votes
2
answers
79
views
Linq how can do null check in where clause?
This is simple linq query
datetime dob = "05152024";
var query = from row in maxLookupData.AsEnumerable()
where row.Field<DateTime>("bar")) <= dob
select row;
In ...
0
votes
3
answers
215
views
error Unable to cast object of type 'System.Collections.Generic.List` to type 'System.Collections.Generic.IList` via bindinglist in VB.NET
I have 2 errors, namely :
Unable to cast object of type 'System.Collections.Generic.List`1[VB$AnonymousType_15`7[System.String,System.String,System.String,System.Object,System.Object,System.Object,...
0
votes
1
answer
128
views
IEnumerable to datatable [duplicate]
Please tell me how to write the result of a query in a DataTable?
var result = from clients in Clients_dt.AsEnumerable()
join cities in Cities_dt.AsEnumerable()
on ...
0
votes
1
answer
72
views
What is the Execution Location for the below Snippet?
Explain the location of each operation i.e WHERE and TAKE.
In Memory or on Database side for both IEnumerable and IQueryable.
IEnumerable<Student> listStudents = DBContext.Students.Where(x =>...
0
votes
0
answers
65
views
LINQ query expression vs using IEnumerable.Where and IEnumerable.Select
I'm coming to C# from Python where we have generator comprehensions such as
nums = range(2, 10)
evenSquares = (num*num for num in nums if num % 2 == 0)
for evenSquare in evenSquares:
print(...
0
votes
1
answer
83
views
Difference between using consecutive OrderBy()'s instead of ThenBy()
I am confused as to why these two pieces of code creates two different results. I would expect the second one, using ThenBy() to generate the correct result, but it does not. The first one (something ...
0
votes
1
answer
136
views
Enumerable.SelectMany throws Error CS0411 - cannot be inferred from the usage
I'm using c#, .net 6.0
I'm trying to convert IEnumerable method and ot's caller method to work asynchronously.
I have a code that looks something like that:
public IEnumerable<MyUser> ...
1
vote
3
answers
97
views
Merge 3 IEnumerable<Application> lists into one
I have simplified my problem
public class Application
{
public int Id { get; set; }
public int Version { get; set; }
public int Status { get; set; }
}
My 3 lists:
IEnumerable<...
4
votes
1
answer
423
views
How does .Where in LINQ actually work under the hood?
In the book "C# in a Nutshell" by Joseph Albahari, it's said that .Where is implemented like below:
public static IEnumerable<TSource> Where<TSource>(this IEnumerable<TSource&...
0
votes
2
answers
73
views
Simplify linq statment (Sonar2971)
I have this Linq:
MyCars refCar = m_service.Cars?.ToList().FirstOrDefault(x => x.Id == car.refId);
...
return m_otherService.GetCar(refCar.RefCardId);
SonarCloud is showing: S2971 - "...
-1
votes
1
answer
69
views
Recursively Iterate over JObject and find duplicates for attribute title's value
This is sample JSON im working on :
string json = @"{
""children"": [
{
""children"": [
...
0
votes
1
answer
65
views
Select item for first list<T> by comparing with another list<Y> using linq or lambda expression
In the below code, the result returns list of bool, whereas I am expecting it to be List of BState. This should satisfy the condition mentioned in the query.
How this can be achieved. Please can ...
0
votes
1
answer
55
views
C# dynamically group based on a condition
I am trying to dynamically group a list based on a certain condition like this:
var groupedList = applyChargeActive
? dataList.GroupBy(s => new
{
s.Id,
s.ValidFrom,
...