Skip to main content

All Questions

Tagged with
-1 votes
0 answers
29 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 ...
hud. 's user avatar
  • 168
0 votes
1 answer
42 views

2 LINQ queries use the same joins. Is there a way to "factor out" the joins and gain a performance benefit?

Here are two example queries: var queryA = from t1 in context.T1 join t2 in context.T2 where tl.colA == desiredColAValue select new ObjectA(valuesFromQueryA) ; var queryB = ...
rob.loh's user avatar
  • 13
2 votes
2 answers
39 views

How to handle the possibility of expected null properties in a LINQ were clause?

Consider the following C# Code Fragment: public class Person { public int Id { get; set;} public string? Name { get; set;} public string? Description {get; set;} } List<Person>? ...
William Holmes's user avatar
0 votes
0 answers
60 views

How do I set SQL Provider in C# Linq

I changed the default collation of my SQL Server 2022 database (and all string objects that already existed) to Latin1_General_100_CI_AS_SC_UTF8. Unfortunately, Linq seems unable to handle this ...
awba's user avatar
  • 1
-1 votes
1 answer
41 views

Insert prefix in a Xml string [duplicate]

I need to be able to write this Xml string: <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:a="http://www.w3.org/2005/08/addressing" ...
Modest's user avatar
  • 13
1 vote
1 answer
54 views

C# linq Include OrderBy

I need some help sorting data by Included data. In the example below, I am returning a purchase order where I want to sort the purchase order line items by the line item id. return await context....
michael's user avatar
  • 35
-1 votes
1 answer
56 views

Equals method never called by LINQ expression [duplicate]

My data class: using System; using System.Collections.Generic; using System.ComponentModel; using System.ComponentModel.DataAnnotations; using static iText.StyledXmlParser.Jsoup.Select.Evaluator; ...
janci's user avatar
  • 403
1 vote
4 answers
47 views

Apply Group by to dictionary value

I have a Dictionary which key of string type and value of list of integer type, like this: Dictionary<string, List<int>>. Lets say I add elements to it: Dictionary<string, List<int&...
sst's user avatar
  • 23
-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(); ...
anvesh's user avatar
  • 77
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....
Hui Jin's user avatar
  • 19
1 vote
1 answer
52 views

LINQ group with list inside shows only the first row

I have a view in the v_PortalProprietario database that returns in each line the name of the owners that are repeated and the accounts (Acertos) that are unique. I would like to make a query in Linq ...
dgbrazil's user avatar
0 votes
1 answer
59 views

Convert List<Task<T>>> to List<T> [duplicate]

I have this variable that should project and return a list of AttachmentRequestModel as follows : var mappedAttachments = recordAction .PPAttachments .Select(async x => new ...
Voice Of The Rain's user avatar
0 votes
2 answers
55 views

How to join tables and group the results using LINQ?

I have a table of Products and a table of Product_Images with a one to many relation (one product can have multiple images) and I am trying to retrieve all products with their related images. So far I ...
SeptimaEspada's user avatar
0 votes
1 answer
59 views

Entity Framework Core : Include not working for many-to-many relationship

I'm having trouble with .Include() not working for many-to-many relationships in Entity Framework Core. My setup works fine for one-to-many relationships, but the related entities are not being loaded ...
shuvo's user avatar
  • 174
0 votes
1 answer
54 views

Pagination on the result from multiple collection .net

I am trying to add offset pagination( input is pagesize and limit) on combined result which is aggregating multiple collections. Earlier I had only limit on the reponse. Below is the code for the API ...
Divya Vyas's user avatar

15 30 50 per page
1
2 3 4 5
4440