Questions tagged [linq]
Language INtegrated Query (LINQ) is a Microsoft .NET Framework component that adds native data querying capabilities to .NET languages.
602 questions
4votes
2answers
238views
Sorting and filtering using dynamic parameters
I have this code which I am upgrading to .NET 8. The intention is to sort and filter the resultset using the parameters. Right now it has a lot of if else and redundant code inside the blocks. I would ...
-1votes
1answer
252views
Optimizing LINQ Query on C# Web API
Can someone help me optimize this code especially the LINQ query. It takes 8-12 seconds just to return a response when I'm calling the endpoint. Its super slow, and my whole endpoint call is taking ...
2votes
1answer
213views
IEnumerable<T>.Tee implementation
I am trying to write A C# version of a method in the Java Stream API called Collectors.teeing() (It's like Aggregate but with multiple accumulator functions), just for educational purposes. I want to ...
10votes
3answers
6kviews
Filter out nulls from sequence of nullables to produce sequence of non-nullables
While introducing nullable reference types to our enterprise application's codebase, I found that we are often using LINQ on sequences of nullable reference types where we filter out the nulls using <...
1vote
1answer
1kviews
Basic ATM Software from a Udemy Project
Recently starting to learn programming, I'm looking to move to making larger projects and am just picking up the basics now. I have a feeling this code sort of missed the point? Am looking for ...
2votes
2answers
130views
Project sequence to multiple sequences using LINQ (or extension methods)
I'm creating a method that expands a sequence. This is a sample of how it works: Input: {1, 2, 3} Output: {1}, {1, 2}, {1,2,3} So far, I've been able to solve the ...
4votes
1answer
1kviews
Transliterate between Cyrillic and Latin scripts
I want to get a code review on the following transliteration code. I wrote it because there were some libraries that I have tried and they were specifically failing with the name "Yuliya" ...
1vote
2answers
589views
Find the newest file that contains a specific string in every subdirectory of the path using the least resources
I have a server side logs folder that contains many hundreds of logs most of which are in subdirectories according to the machine the logs have come from. The task is to extract the full path of the ...
3votes
1answer
123views
"Select followed by First" versus "First followed by Select" when summing the data for a student
I am wondering which one I should choose between the following two options when I need to calculate the sum of Data of the student with ...
0votes
4answers
2kviews
Checking a value in a string array in C# [closed]
I want to see if there is a cleaner way to do this logic. I have a working sample: Same fiddle.net ...
1vote
2answers
372views
Is there a way to use lambda function to get the list?
I have a data set. ...
1vote
2answers
109views
Is there a way to simplify getting the character that appears the most in a collection with Linq?
I have a collection of strings, all of which are three characters in length: ...
1vote
2answers
102views
Efficiency of finding one database record using two ID's
I'm using C#, .NET Core and the entity framework and am currently working on optimizing various functions for better performance. One of the main functions is getting a calculation based on two ...
1vote
1answer
542views
1vote
1answer
113views
Reading data from a CSV and pushing it to a Salesforce application
I'm trying to write code that reads data from a CSV and pushes it to a Salesforce application using the API. My code processes the data in a for loop, but it takes a long time (3 hours) to run the ...