Tagged Questions
Language INtegrated Query (LINQ) is a Microsoft .NET Framework component that adds native data querying capabilities to .NET languages.
-2
votes
0answers
39 views
Building lists of users and roles for ASP.Net/C# user-management page
I have a user management page that works decently right now with the exception it can take about 5 seconds to load. Testing shows that is it the code I am using to build lists. I was hoping to get a ...
2
votes
2answers
50 views
Locating people by roleId
Basically, I'm trying to find all active people with a roleId of 3 (analyst id). But I want to exclude ids that were created as test analysts, i.e. "130", "252", ...
4
votes
1answer
40 views
Linq-like functions in JavaScript
Today was my first day working with JavaScript and I tried to implement some Linq-like (C#) functions as extension methods.
I'm pretty new to JavaScript and wanted to ask you for checking my ...
-2
votes
1answer
51 views
Linq query combining three tables [closed]
I have a linq query that combines three tables:
Users,
Products, and
User_Has_Products
I ...
2
votes
1answer
79 views
IQueryable left outer join linq extension
I wanted to create an extension method to enable left outer joins in linq/lambda IQueryables, and I have come up with the following, but I am still not sure it's completely correct.
...
2
votes
2answers
219 views
Updating database based on selected check boxes
I posted the original question here, but I think it would be nice to have someone else's eye on this code for improving it.
...
4
votes
2answers
93 views
Constructing file paths for each row of a datatable in C#
I need to iterate through a DataTable and columns in each rows and do some data manipulation.
Below given is an extract from my code, I use c#.net. I expect maximum rows in datatable will be less ...
5
votes
2answers
92 views
Get XML elements with a particular attribute value
I have the following code to find xml elements that have a particular attribute value:
...
9
votes
4answers
171 views
+50
LINQ to SQL query filter, with the name match ignoring multiple punctuation characters
I have the following LINQ to SQL query which works fine but looks ugly:
...
8
votes
2answers
159 views
5
votes
1answer
162 views
Climbing the stairs
A quick description on the problem I solved on codewars.com but remember I just want a small part of my solution refactored (just the for-loop):
Description
...
3
votes
3answers
123 views
Sort and merge list based on another list
Here I'm merging a list to end of another list after sorting it according to another list.This should sort processdetails list according to the order in routeplans list if any item not present in ...
3
votes
5answers
435 views
Check if the user exists
Scenario:
Check if the user exists
If yes: update the details
Else: insert the user details
...
7
votes
4answers
357 views
Using LINQ to group social networking links for each user
I have a model named User. Each user can have some social links. Now I want to get all users with their social link as a single row in the result. Here are my ...
11
votes
4answers
2k views
Country code lookup for each line in a CSV file
I'm trying to write a program that has a for loop, inside of which I have lambda expression to get a certain value. The loop has about 20,000 iterations. Including ...
4
votes
2answers
76 views
Transform a List of objects to a string of unique values for use in an SQL query
I have a List of Results. My goal is to extract the Result property ...
5
votes
3answers
260 views
HackerRank woman codesprint: minimum cost
Lauren has a chart of projected prices for a house over the next n
years, where the price of the house in the i-th year is <...
4
votes
1answer
57 views
IQueryable Extensions working on expression for collection property
Followup to Repository searching code duplication
My goal currently is to make my current implementation of my repository's IQueryable filtering less duplicative. First, I looked into passing ...
4
votes
2answers
165 views
Migrating data using entity framework, linq and recursion
I have a piece of code to migrate data from an old app to a new app. The data represents the user's websites.
In the old app the user only had one section for websites, on which you could add any ...
4
votes
1answer
88 views
Retrieving website categories from a three-level hierarchy
I've been trying to fix this performance bottleneck in my web app for a while now.
Here is what the data looks like on my web page:
Here is how I get this data in the controller:
...
3
votes
1answer
62 views
Unfold a 2D array spiral in C#
The purpose of this function is to turn a 2D array of sorts into a single-dimensional array by reading it in a spiral fashion.
In the array:
1 2 3
4 5 6
7 8 9
...
2
votes
3answers
152 views
Pangrams implementation using Linq
This is a continuation of my LINQ stories from Pangrams-Hackerrank. Similarly, this challenge has been asked before in python Pangrams python Implementation but I have tried to accomplish this ...
3
votes
2answers
72 views
Diagonal difference using Linq
Recently, I have been trying my hands on LINQ. So I've implemented the diagonal difference using Linq in Hackerrank. I know a similar question has been asked in python Diagonal Difference
Here is ...
3
votes
2answers
122 views
Implementing SOLID Principles - LINQ TO SQL
I have been using Layered Architecture in my web application. Can anyone please advise if my data layer classes (both Linq and booking class) can be improved?
I have just started learning about solid ...
4
votes
1answer
139 views
Chunking a list into separate lists of 5, and then iterating through each
I'm writing a service that receives a list of Latitude/Longitude objects, prepares them for transaction, and then calls a web service to write them to the organization's Mainframe. According to the ...
1
vote
0answers
70 views
XML settings file read/write Design Patterns [closed]
I'm new to C# and would like to create a WPF app with xml config file. I have a certain setting file written by using System.Xml.Linq;.
And I'd like to write ...
1
vote
2answers
69 views
Filtering data for jQuery DataTables
Using DataTables (Table plug-in for jQuery) with server-side processing, I had to create filtering for my data with good performance. However, in my opinion it's kinda ugly, especially the part of (<...
11
votes
6answers
2k views
Too Many Staff Meetings
I recently got in really deep on a question to find the overlapping meetings and I rewrote a bit of the code and added some things to the code, and I would just like a general review of my code and ...
3
votes
2answers
279 views
Creating monthly files from an annual file
I am interested in learning a more succinct (or better performing) way of writing the following working code. I just figured it out but it is pretty messy. This program takes a file full of daily ...
4
votes
1answer
63 views
Delete records from multiple tables when deleting a subproject [closed]
In my program I am deleting subprojects using LINQ. It's incredibly slow. There is a lot of cascade on delete's here so I am deleting from multiple tables. Any help and tips would be appreciated.
...
3
votes
3answers
147 views
Factoring WHERE clauses in IQueryable
I recovered some spaghetti code and I have to refactor it. I do not want a method with over 200 lines, for me it is not object oriented programming. I am trying to ponder on the question and would ...
1
vote
2answers
110 views
Reading in a file and ranking result to output file
I am reading in a file which consists of scores between two teams. The team that wins gets 2 points, if the teams tie both teams get one point. The result is ranked by points and if there is a tie ...
4
votes
3answers
146 views
Concatenating two IEnumerables with a limit
I've been playing around with generators, generics and extension methods in C# (5.0) and wanted to create an extension method for IEnumerable, which would append ...
2
votes
2answers
173 views
Creating a random code and saving if it does not exist
I have created a script to generate 5 random codes, check if any one of them exists in the database, and if not, insert the record. The script will throw an exception if a single code could not be ...
1
vote
1answer
86 views
Simple generic linq expression generation method
Here is my generic method for creating linq expression based on field name of a type, operator (as enumerations of operators generated from XSD) and value of field
...
0
votes
2answers
66 views
LINQ sorting using custom IComparer is very slow
Joining a project with some crazy LINQ sorting statements and after refactoring by the team using a custom comparer we found out that it is so slow for some data that you actually think it is an ...
5
votes
2answers
111 views
LINQish command line parser
I needed to parse some command line switches from a string and I tried to do it the easy way so I just wrote this:
...
4
votes
2answers
68 views
Search for variants of keywords using LINQ
First, I'm adding words entered into a search field to an array. Then, I'm getting results from a stored procedure on SQL Server using Database First approach with Entity Framework.
Finally, for ...
8
votes
1answer
121 views
Linqy Sudoku game generator
I created a class that is able to generate a Sudoku board.
The following board generation steps are made:
Create a valid board with numbers on all squares, row by row
Basically I always generate ...
2
votes
2answers
826 views
Check if an Array of Arrays contains a value in node js
In C#, I could check if any of the nested List collection has a value. Example of such structure Check a List[]> contains a value using Linq
...
6
votes
3answers
274 views
Checking whether relations are equal to foreign fields using LINQ Any()
Can you find a more understandable way to write the following one-liner?
...
3
votes
3answers
73 views
Add multiple instances of a property to a list [closed]
I'm a novice programmer asking first question here although I've gotten tons of help from previous questions.
The following code is abstracted from what I currently have working.
...
10
votes
4answers
328 views
Split IEnumerable by predicate
In order to divide an IEnumerable in C# by a predicate, I implemented the following (in a static class):
...
2
votes
1answer
36 views
Sort group item by attribute
I have a repository method which retrieve a list of items, for example:
...
7
votes
1answer
117 views
LINQ Provider: Supporting Projections
Up until recently, my LINQ-to-Sage provider didn't support projections, so the client code had to explicitly "transfer" to LINQ-to-Objects, like this:
...
-1
votes
1answer
72 views
3
votes
2answers
139 views
Countable and uncountable sets in .NET (IEnumerable and Predicate)
There is a full featured support of countable sets in .NET: IEnumerable<T>. What about uncountable sets; sets defined by predicate? How can they be ...
4
votes
1answer
76 views
Loading and updating data from system A to system B
I need to transfer purchase order (PO) information from SQL Server into Sage 300 ERP, so using my Linq-to-Sage implementation, I wrote a little console application that connects to a SQL Server ...
0
votes
1answer
58 views
Is my LINQ query safe and efficient?
I am relatively new to LINQ queries as I normally just use plain SQL to get my data back but i am changing for the good - Anyway obviously with SQL you pass in parameters so you do not get any SQL ...
2
votes
3answers
658 views