Skip to main content
OverflowAI is here! AI power for your Stack Overflow for Teams knowledge community. Learn more
4 votes
Accepted

GET with paging, sorting and filtering

//countQuery mirrors query through the filter assignments I don't think that's necessary. You could have only one query for the first part of the method, then do <...
svick's user avatar
  • 24.3k
4 votes
Accepted

Calculating the .Sum() in Linq-to-SQL

You have: if (db.BadgeAssignments.Any(bba => bba.UserIdReceiver == newbadgeassignment.UserIdReceiver && bba.BadgeAssociated.CourseId == courseId)) And ...
Mathieu Guindon's user avatar
4 votes
Accepted

Returning an IEnumerable using Linq-to-SQL which is then bound to a GridView

First, the fact that your methods are static, and accessing what appears to be a static, disposable field, scares me: your application quite possibly has structural ...
Mathieu Guindon's user avatar
3 votes
Accepted

Exporting test results to PDF tables

Some quick remarks: pid, dateofvisit, stamp, type are ...
BCdotWEB's user avatar
  • 11.2k
3 votes
Accepted

Selecting employees in certain departments using LINQ

lstdepartment We don't use Hungarian notation with prefixes like lst in C#. It's just ...
t3chb0t's user avatar
  • 44.3k
3 votes

A generic way to use LINQ to Entity with types and operations unknown until run time

Look at the PredicateBuilder on LINQKit. These code snippets are from the linked page: ...
Sean Newell's user avatar
3 votes

LINQ to SQL query filter, with the name match ignoring multiple punctuation characters

You are rather removing those parts instead of replacing them, so more appropriate name would be remove all. You can make your own extension method like this : ...
Denis's user avatar
  • 8,478
2 votes

LINQ to SQL query filter, with the name match ignoring multiple punctuation characters

...
t3chb0t's user avatar
  • 44.3k
2 votes

Efficiency of a linq query on a nested structure

Keep your database access as short (queries and time) as possible. There are two main reasons to do that: Detach how and where you get the info from (tomorrow it may come from the network... ot ...
A Bravo Dev's user avatar
2 votes

Efficiency of a linq query on a nested structure

It runs 4 queries for every question in the survey because of the line that calculates the percentage. You're trying to retrieve data and make calculations at the same time. The issue stems from ...
Flater's user avatar
  • 5,532
2 votes
Accepted

Aggregating clients and client types

You should not need to populate the ClientTypes property with your own query. Usually it is handled by a navigation property that already knows how to handle ...
t3chb0t's user avatar
  • 44.3k
2 votes

Exporting test results to PDF tables

A few observations, in addition to what BCdotWEB already pointed out: There's a fair bit of repetition in that switch statement. You're using a type ID to look up a specific ...
Pieter Witvoet's user avatar
1 vote

Linq Conditional where clause when parameter can be null

Query syntax for Linq here makes this harder than it should be. I'd recommend using Linq's method syntax because it can be built ...
Michael Rieger's user avatar
1 vote

Data validation for to check required fields are mapped

For readability I'd separate this into steps. Instead of doing your query within the declaration of your for loop, do it first. ...
Scott Hannen's user avatar
1 vote

LINQ to SQL query filter, with the name match ignoring multiple punctuation characters

You could write extension method that combines Replaces and returns new query. ...
Oleg's user avatar
  • 119
1 vote

LINQ to SQL query filter, with the name match ignoring multiple punctuation characters

You could create the following helper extension method: ...
Dmitry's user avatar
  • 4,589
1 vote

Implementing SOLID Principles - LINQ TO SQL

This is unusual: ...
Mathieu Guindon's user avatar
1 vote

Implementing SOLID Principles - LINQ TO SQL

LinqDatabase and DI Well, the virtually hardcoded connection string and the timeout hurt testibility. The connection string should be a parameter of the constructor. You can use a default value but ...
t3chb0t's user avatar
  • 44.3k

Only top scored, non community-wiki answers of a minimum length are eligible