Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.

Questions tagged [linq]

Language INtegrated Query (LINQ) is a Microsoft .NET Framework component that adds native data querying capabilities to .NET languages.

Filter by
Sorted by
Tagged with
5 votes
2 answers
270 views

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 ...
codeandcloud's user avatar
-1 votes
1 answer
304 views

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 ...
Kraust123's user avatar
2 votes
1 answer
230 views

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 ...
Dennis_E's user avatar
  • 1,210
10 votes
3 answers
6k views

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 <...
Palec's user avatar
  • 201
1 vote
1 answer
1k views

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 ...
Th3 M0rrig4n's user avatar
2 votes
2 answers
141 views

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 ...
SuperJMN's user avatar
  • 233
4 votes
1 answer
2k views

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" ...
nop's user avatar
  • 819
1 vote
2 answers
621 views

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 ...
Richard Payne's user avatar
3 votes
1 answer
135 views

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 ...
Display Name's user avatar
0 votes
4 answers
2k views

I want to see if there is a cleaner way to do this logic. I have a working sample: Same fiddle.net ...
Jefferson's user avatar
  • 123
1 vote
2 answers
397 views

I have a data set. ...
Hello's user avatar
  • 113
1 vote
2 answers
138 views

I have a collection of strings, all of which are three characters in length: ...
Taco's user avatar
  • 929
1 vote
2 answers
134 views

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 ...
RDAxRoadkill's user avatar
1 vote
1 answer
567 views

Code ...
kuch's user avatar
  • 165
1 vote
1 answer
135 views

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 ...
Ahmed Mujtaba's user avatar
0 votes
1 answer
5k views

I have a object list like below. I want to join every two rows into single row based on column B. It is sure that only two rows would be there for every single column B value. Input Output However, ...
Rahul's user avatar
  • 101
-2 votes
1 answer
130 views

I have written one method; however I feel I can refactor it even more but not sure what Can someone help me here? ...
Chandler's user avatar
1 vote
1 answer
419 views

I have this class representing a period of time: ...
Arcord's user avatar
  • 113
6 votes
2 answers
1k views

I am writing a piece of code for C# Web Api, letting the clients to pass a column name and sort direction as parameter. Although there are, like, 30-ish properties, so the following code (despite it ...
user avatar
1 vote
1 answer
179 views

I would like to convert a list A A = {1, 12, 3, 3, 3, 8, 5, 5 } into list B ...
SuperJMN's user avatar
  • 233
0 votes
1 answer
92 views

Currently I have this code: ...
Gauravsa's user avatar
  • 131
1 vote
2 answers
420 views

I have created helper class for configuration validation, the main purpose is to find any human "errors" in the configuration for the app. the case is that any type of "message" ...
Arkady Levin's user avatar
0 votes
1 answer
240 views

The code below selects all items that are locked. How can I optimise it? ShopItemData doesn't contain a field for locked/unlocked. ...
Çağatay IŞIK's user avatar
1 vote
2 answers
191 views

I have the following method that I am trying to optimize. Currently, the method works great, however, it takes a little over 3 hours to complete. I feel like, using some nifty LINQ joins, it should be ...
Icemanind's user avatar
  • 188
4 votes
1 answer
7k views

As you might know, EF Core does not support executing multiple queries in parallel on the same context using something like Task.WhenAll. So you have to write this ...
wertzui's user avatar
  • 188
4 votes
0 answers
161 views

I have two entities in my database: Employee and Shift. I want to implement a C# repository pattern method, that given two ...
Jens Jensen's user avatar
7 votes
2 answers
4k views

I am trying to build this view model that has a ChildViewModel and this was the only way I was able to get it working. Any advice on how to make this code; cleaner, more effective, just overall better!...
Jefferson's user avatar
  • 423
5 votes
3 answers
12k views

I have this code that gets a CSV string from a list of objects where the first row in the string is the object's properties and the rows underneath are the properties values. I then create a ...
Jimenemex's user avatar
  • 185
2 votes
1 answer
388 views

Currently, I have a code which downloads a file from FTP to local hard disk. It then uploads a file in chunks to Azure. Finally, it deletes the file from local and ftp. This code is very slow though. ...
Gauravsa's user avatar
  • 131
5 votes
1 answer
8k views

I have a List that I want to compare to an Enum. If a.Value is found in the Enum we return <...
indofraiser's user avatar
2 votes
1 answer
2k views

I wrote this piece of code which works as expected: ...
Kasrak's user avatar
  • 135
2 votes
1 answer
96 views

Any advice on how to make this code; cleaner, more effective, just overall better! Program has three options that can be passed int NewsId,Year and CategoryId. I collection all the data and then do ...
Jefferson's user avatar
  • 423
1 vote
2 answers
208 views

I am trying to generate a Word document with two different tables inside it. For this purpose I have two similar methods where I am passing word document reference and data object and table to the ...
Glory Raj's user avatar
  • 189
1 vote
2 answers
820 views

RNA can be broken into three nucleotide sequences called codons, and then translated to a polypeptide like so: RNA: "AUGUUUUCU" => translates to Codons: <...
Milliorn's user avatar
  • 610
4 votes
3 answers
328 views

...
Nɪsʜᴀɴᴛʜ ॐ's user avatar
4 votes
3 answers
214 views

Here I go again. I have been finding a fairly common pattern in business logic code. And that pattern looks like this: ...
Jesse C. Slicer's user avatar
6 votes
5 answers
1k views

Given an array a, find the greatest number in a that is a product of two elements in a. If there are no two elements in a that can be multiplied to produce another element contained in a, return -1. I ...
Milliorn's user avatar
  • 610
7 votes
1 answer
13k views

LINQ Select usually works like this: IEnumerable<Task<int>> res = new[] {1,2,3}.Select(async i => i); I would ...
Dmitry Nogin's user avatar
  • 6,131
4 votes
2 answers
2k views

I have here some methods which reverse string characters. Example if given string is "HELLO", it will returns "OLLEH". Are my big o notation for these approaches correct? And which approach is the ...
Steve Ngai's user avatar
6 votes
1 answer
166 views

I'm creating mazes, and have a Cell class (only relevant code shown)... ...
Avrohom Yisroel's user avatar
1 vote
0 answers
1k views

I have been looking for the best approach to creating an extension method that would give me the ability to select in a linq query using async/await with a max degree of parallelism. I'm aware that ...
TheRock's user avatar
  • 171
1 vote
0 answers
473 views

I'm in the process of implementing a fully generic service to filter out entries (of any type), which are contained in a ICollection. As it is generic, without any ...
Philippe's user avatar
  • 111
1 vote
0 answers
145 views

Well, I'm working with Selenium to scrape a webpage that has obfuscated class names (example <div class="example-gHJkLM">...)... So I needed to ...
z3nth10n's user avatar
  • 247
2 votes
0 answers
116 views

The desired behavior would be: ...
Dmitry Nogin's user avatar
  • 6,131
4 votes
1 answer
736 views

I am writing a domino draw game in C# and would like to know if there is a simpler/better way to know the player that has been dealt the highest double bone (where x equals y) and what bone it is: <...
Alex's user avatar
  • 165
4 votes
3 answers
5k views

A bit of background. In the application I work on there are emails sent to notify users about articles they need to review. Each email+recipient pair is stored in database and may be assigned a ...
jakubiszon's user avatar
18 votes
6 answers
6k views

The Fizz Buzz challenge is well-known and should not need any explanations, right? I recently got a bit bored and came up with a solution for Fizz Buzz using LINQ and even asynchronous code and a lot ...
Wim ten Brink's user avatar
12 votes
2 answers
2k views

LINQ/FP style: Assert.IsTrue(new[] {1,2,3}.AnyPairSum(4)); Where: ...
Dmitry Nogin's user avatar
  • 6,131
5 votes
0 answers
152 views

WiKi and GitHub. Sudoku rules are being checked with the following tests: ...
Dmitry Nogin's user avatar
  • 6,131
7 votes
2 answers
502 views

Funny thing, the following test works: ...
Dmitry Nogin's user avatar
  • 6,131

1
2 3 4 5
13