Skip to main content

All Questions

Tagged with
-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 ...
bairog's user avatar
  • 3,271
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 ...
Software Enginner's user avatar
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,...
user avatar
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 ...
sereganator's user avatar
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 =>...
rohan's user avatar
  • 61
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(...
joseville's user avatar
  • 831
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 ...
Andreas's user avatar
  • 137
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> ...
Amir M's user avatar
  • 536
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<...
Roger Uhlin's user avatar
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&...
jon bee's user avatar
  • 83
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 - "...
4est's user avatar
  • 3,116
-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"": [ ...
SELA's user avatar
  • 5,968
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 ...
AMIT SHELKE's user avatar
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, ...
sapter's user avatar
  • 324

15 30 50 per page
1
2 3 4 5
67