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
1answer
94 views

Picking a random neighbouring cell, but only picking previously-visited ones if there aren't any unvisited

I'm creating mazes, and have a Cell class (only relevant code shown)... ...
1
vote
0answers
85 views

SelectAsync With Max Degree Of Parallelism

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 ...
2
votes
0answers
56 views

Generic search service to filter entries in lists

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 ...
1
vote
0answers
24 views

Getting all descendants IWebElements (using XPath) is too slow in Selenium

Well, I'm working with Selenium to scrap a webpage that has obfuscated class names (example <div class="example-gHJkLM">...)... So I needed to create an ...
1
vote
0answers
80 views

get better performance [closed]

I have this code that works, but I'm sure that it can be done better, any suggestions? ...
2
votes
0answers
80 views

LINQ extensions for sequence comparing

The desired behavior would be: ...
3
votes
1answer
110 views

C# Linq search list within list

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: <...
4
votes
3answers
97 views

C# + Linq - grouping objects by frames of time found in the data

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 ...
17
votes
6answers
6k views

Solving Fizz Buzz using LINQ in C#

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 ...
12
votes
2answers
1k views

Given an array A[] and a number x, check for pair in A[] with sum as x

LINQ/FP style: Assert.IsTrue(new[] {1,2,3}.AnyPairSum(4)); Where: ...
4
votes
0answers
97 views

Implement Sudoku using LINQ

WiKi and GitHub. Sudoku rules are being checked with the following tests: ...
0
votes
0answers
58 views

GCD Groups with list

We have a list. divide the list element into two groups such that when the product of the numbers of two groups is taken and their GCD is calculated, it came out to be 1. Answer the number of ways in ...
7
votes
2answers
148 views

Iterate only once using LINQ

Funny thing, the following test works: ...
4
votes
1answer
67 views

Paginate IEnumerable<T> sequence

I used the following to split sequence into batches: ...
4
votes
2answers
125 views

Finding which items have at least one common value with other items

I have the following collection : ...
1
vote
1answer
66 views

ASP.NET MVC 5, EF 6 filter performance

I'm creating a filter with Linq in an ASP.NET MVC application. I was hoping I could get some tips on performance enhancements, aside from any possible performance enhancements. I have a few questions:...
7
votes
3answers
595 views

LINQ Extension methods MinBy and MaxBy

LINQ Extension I present a LINQ method ArgBy that returns the item of a sequence that corresponds to the predicate specified. Two additional methods ...
4
votes
2answers
88 views

Reverse Dictionary: Group from child array elements and get its minimum key

Objective I have following array and would like to group by each child and get its smallest Id:- ...
4
votes
2answers
135 views

DropDown tree with search

I fetch a bunch of categories for a DropDown tree, and have to implement search in this dropdown. If there is a match in one of the elements, it should also get all ...
5
votes
1answer
303 views

Make utility using LINQ

Make() takes projects with a list of tuples representing project references in the form of (Dependency, Dependent) and returns ...
6
votes
4answers
2k views

LINQ for generating all possible permutations

Permutate() is supposed to generate all possible permutations of the source sequence: ...
3
votes
1answer
81 views

LINQ for extracting N bottom items (async streams)

source.Bottom(n, x => x) should be the same as well known LINQ source.OrderBy(x => x).Take(n) but is more memory/run-time ...
9
votes
4answers
943 views

Filter search results by multiple filters in one operation

I want to filter search results by multiple filters at once. Is it possible to reduce the number of if statements? My code: ...
1
vote
0answers
113 views

E-Commerce Mock App in Console

I have completed this E-Commerce Mock App in Console C# which I used object to store the data to apply some C# OOP and LINQ techniques. Since it is just a mock version, features are reduced to the ...
16
votes
3answers
2k views

ExactlyOne extension method

I often find in codebases something on the order of if (sprockets.Count() > 0) which is easily replaced with LINQ's ...
5
votes
2answers
121 views

PLINQ code analysis in terms of efficiency of cryptographic hashes generation

I have the following code that I wrote in order to find the correct password by generating hashes out of all possible combinations and comparing each of them with the target. I'm trying to make ...
7
votes
5answers
539 views

Grouping into more groups in one iteration

I had a need to group the same dataset in several groups. So instead of repeatedly query the dataset, I made an extension that could do it once. The caveat is, that the result is materialized in ...
5
votes
3answers
289 views

SkipLast of an IEnumerable<T> - Linq Extension

As my answer to this question, I came up with this solution: ...
2
votes
1answer
122 views

Performance issue with empty lists

Here's my updated version of the problem I posted at Calculating time windows for entities, adding in suggested changes as well as a change I did so that the Reflection is 'cached' in a ...
2
votes
1answer
59 views

Populating dropdown lists, using SQL vs. using expression trees and reflection

I'm working with a large enterprise SQL Server database with dozens of tables that are used mainly as lookups to populate dropdown lists, etc. These tables all follow the convention of having (table)...
3
votes
1answer
217 views

Non brute force algorithm for Birthday Chocolate

Problem: https://www.hackerrank.com/challenges/the-birthday-bar/problem Lily has a chocolate bar that she wants to share it with Ron for his birthday. Each of the squares has an integer on it. She ...
3
votes
0answers
29 views

Configure multiple application features by common criteria

My FeatureSerivce provides only basic APIs, so it is good in dealing with single features. Like I can configure only one feauture at a time: ...
2
votes
2answers
43 views

LINQ queries to generate a report on accrued work time on projects

The following code fetches data from a MySql database to generate a simple report on accrued work time on projects. I've been away from Entity Framework for a while and looking at this code you can ...
0
votes
2answers
171 views

Poker Hand evaluation

I want to evaluate Poker Hands an wrote the following Code: https://dotnetfiddle.net/mxMvq9 Anything wrong / to imporve? ...
6
votes
5answers
230 views

Take N elements from List of Lists

I've come with a solution super tricky for a simple requirement. I think I could solve the problem using LinQ, but I'm not seeing it so clearly at all. What's sure, I'm not comfortable with my code. ...
3
votes
2answers
247 views

Group list into elements with same value

This is my Result class: ...
2
votes
1answer
74 views

Parse through an XDocument efficiently and match values to matching object

Minimum viable test program: ...
0
votes
1answer
168 views

LINQ or Lambda for two foreach query [closed]

I have a Document Name Table in my SQL database and Files in the Content folder. I have two lists: ListOfFileNamesSavedInTheDB and ...
4
votes
2answers
123 views

Making a list of customers who buy the top N items from a supplier

I have a method that works perfectly well and does what it's supposed to, albeit a little slow (30 - 40 seconds). I would like to be able to speed it up or at least make it more efficient, any ideas ...
3
votes
1answer
166 views

Logging inside a Linq fluent chain [closed]

I've posted this to Stack Overflow, but someone voted to close as they felt it was opinion based, so I'm bringing it over to Code Review. I have some Linq fluent chains to shape an original ...
1
vote
2answers
568 views

Using IQueryable.GroupBy to count related database entities

Given a DbSet<Client> from an Entity Framework 6 DbContext, I need to count the number of related ...
-2
votes
1answer
907 views

Filtering List data using LINQ [closed]

In this code I have declared myPushData, myPushDataFilterd and myPushDataFilterd2 variables ...
12
votes
1answer
1k views

Linq for ObservableCollection

Purpose ObservableCollection<T> is not strictly a WPF class, but its intended purpose seems to be for use in WPF. It's the standard implementation of ...
3
votes
5answers
725 views

Finding Isogram Word

An isogram (also known as a "nonpattern word") is a word or phrase without a repeating letter, however spaces and hyphens are allowed to appear multiple times. The ...
5
votes
2answers
874 views

Going from IQueryable<IEnumerable<myObj>> to IEnumerable<myObj>

I have a "GetPersonsPerDepartment()" method returning a IQueryable<IEnumerable<Person>> while I'm trying to get a simple ...
1
vote
1answer
1k views

Merging two lists into one by dates [closed]

I have two lists of Slots ...
8
votes
4answers
1k views

Custom implementation of the linq Zip operator for different length lists

Based on my answer I have my implementation of linq Zip operator which operates on different length lists, and loops shortest list. My implementation: ...
-2
votes
1answer
367 views

Method to populate a dictionary from properties

I have a class with some properties. In the class I have a method that is "collecting" all the properties in a specific instance of the class to a dictionary, with the properties name being the ...
-2
votes
1answer
814 views

Reuse Select Expression in LINQ

I have three methods to get the user details based on attributes: Find user details by id, Find user details by username, Find user details by email Here is the program class: ...
2
votes
3answers
275 views

Grouping report data by one of two criteria

I have a report with a group by filter. A stored procedure returns all the data and maps it to IEnumerable<EventListRow>. The code should then group the data ...

1 2 3 4 5 12