All Questions
Tagged with linq performance
1,249
questions
-1
votes
0
answers
26
views
Improving performance of contains method in ASP.NET MVC web application with large dataset
I have an ASP.NET MVC web application using C#, Visual Studio, and SQL Server. This is my code:
if (!string.IsNullOrEmpty(Name))
{
query = query.Where(x => x.PatientName.Contains(Name));
}
The ...
-1
votes
0
answers
63
views
Performance degradation of linq query in C# after .NET Core upgrade to 8 [duplicate]
I have the simple linq query in my .NET Core C# app. We have upgraded from .NET Core 3.1 to .NET 8.
My query is as follows:
Decimal[] cks = mem.Select(a => Convert.ToDecimal(a.KEKE_CK)).ToArray();
...
0
votes
0
answers
93
views
Why this C# code runs slow if the loop is more than 30 times? [closed]
int range = 20;
var test = Enumerable.Range(0, range).Select(i => new Section { Id = i, Value = i }).ToList();
var result = RemoveEvenNum(test);
foreach (var section in result)
{
Console....
0
votes
1
answer
50
views
How to test a method that calls a persistence method returning IQueryable
I read in a few places that it's a good practice for a method that calls the database to return IQueryable because it allows extending queries in services using methods like Select, Where, etc., and ...
2
votes
2
answers
113
views
element-wise add / subtract / multiply / divide operation in two lists in C#
Considering element-wise add / subtract / multiply / divide operation in two lists. I have the code as follows.
public class Calculate
{
public static IEnumerable<T> Add<T>(IEnumerable&...
0
votes
1
answer
47
views
Improve performance of Moving Average calculation. IEnumerable vs List, foreach vs for, ElementAt,
I created a class to calculate a Exponential Moving Average:
public class ExponentialMovingAverage {
public Int32 Period { get; set; }
public ExponentialMovingAverage(Int32 period = 20) {
...
0
votes
1
answer
178
views
Strange performance issue with Where and Endswith, 7 times slower with .NET 8 than with .NET Framework
I discovered a strange performance issue with the following statement, after upgrading the solution from .NET Framework to .NET 8, I've got performance degradation about 7 times slower.
I'm iterating ...
0
votes
0
answers
37
views
Join LinqKit.PredicateBuilder across different Tables C#
I am trying to use LinqKit.PredicateBuilder to return if I should display a certain food drink item.
My setup is, I have a FoodDrinkType table, FoodDrinkLink table, Enquiry table, EnquiryVenue table.
...
1
vote
2
answers
53
views
Linq code improvement issues with filters
I have this linq query:
private async Task<IQueryable<MyModel>> GetClaimList(MyDto input)
{
var claimQry = await _claimRepository.WithDetailsAsync();
var claimBatchQry = await ...
0
votes
0
answers
77
views
Improve C# LINQ query to get the most suitable range among items (based on a condition)
I've got a List with 5 SubItems each.
List consist of ~2 million of records.
These records/items are already sorted/ordered for next queries.
I've got two tasks:
Find the best continuous range of ...
0
votes
1
answer
86
views
Linq Query Performance issue on large number of records using C#
I'm having web application which is built into angularJs, C#, Linq etc.
I'm having almost 2,00,000 lac records on production environment.
Almost each columns have filters (Asc/Desc on click of column),...
0
votes
1
answer
56
views
Cannot perform SelectMany - Unable to materialize collection
query :
var nodes = (from n in _db.TreeNodes.Where(n => passwordCycles.Select(c => c.HorusId).Contains(n.HorusId))
from path in _db.TreeNodes.Where(p => (EF.Functions....
0
votes
0
answers
81
views
Analysis of Null Handling for Max LINQ
I did an analysis of some of the most common recommended methods using BenchmarkDotNet
This include
DefaultIfEmpty
OrderByDescending
And Null Check with Any Clause (DetectIfEmpty)
Through ...
0
votes
1
answer
110
views
Speedup query execution time for this linq query
I have this query that does the following :
Pull childrens from the database
Filter this childrens to get the ones that cannot be join to the availableItems query (that are not in the availableItems ...
0
votes
1
answer
43
views
How can I improve this Entity Framework LINQ query
I have the following EF query that is taking about 20 seconds to return ~100k rows. If I remove the "Addresses" and "Contacts" subqueries (if that's what you call them) in the ...