Skip to main content
13 votes

C# Am I using proper SOLID principles?

I suppose the simplest thing is to go through the principles: SRP - Cannot see any 'too big' things in your example OCP - The example is small enough and you are not using class inheritance that I ...
Jamie Stevenson's user avatar
8 votes
Accepted

C# Convert BLOB to jpg, resize, then back to BLOB

Welcome to CodeReview! I hope you get some good feedback. Absolute paths ...
Reinderien's user avatar
  • 63.1k
6 votes

Factory for report handlers

Not sure if that's going to improve the maintainability index, but You're misimplementing Inversion of Control. IoC is when your dependency (namely, IReportHandler)...
guillaume31's user avatar
6 votes
Accepted

Update SQL database with using statement and SqlParameters

Stacking the using statements I am particularly difficult to please with code that has nesting, and I highly prefer to stack the ...
Svek's user avatar
  • 1,023
6 votes
Accepted

Implementing integration tests in ASP.NET core using InMemory database

I went through the very same conflict and eventually looked at what other frameworks were doing. What you'll find with the above implementation is that it is okay for a couple hundred tests, but soon ...
jaredcnance's user avatar
6 votes

Find consecutive numbers and turn them into ranges

Letting a single method do everything is not such a good idea. You should rather separate the logic for finding consecutive numbers from creating a string from ranges and let them produce the final ...
t3chb0t's user avatar
  • 44.3k
6 votes

C# Am I using proper SOLID principles?

IMO returning IEnumerable<T> from an API is a violation of "L", as running GetEnumerator() a second time (or ...
David Browne - Microsoft's user avatar
6 votes
Accepted

Is this correct way to setup DB Infrastructure with repository pattern and Dapper

Quick remarks: Why do you convert a string to a string: ...
BCdotWEB's user avatar
  • 11.2k
5 votes

Factory for report handlers

Some observations: You shouldn't be creating the factory inside the class that uses it. That defeats its purpose! Instead, you should pass the factory to that class's constructor. You shouldn't be ...
Matthew Watson's user avatar
5 votes
Accepted

Online examination portal for learning

Overall, I think this code is a great first try. That said, it has a lot of room for improvement in terms of simplification and improving readability. As an aside, I'm not sure if you have a strong ...
Matthew FitzGerald-Chamberlain's user avatar
5 votes

If and else without curly brackets

Is it possible to have an if condition with curly brackets and else conditions without brackets? Or course it's possible. You don't even need new lines and can write everthing like this: ...
t3chb0t's user avatar
  • 44.3k
5 votes
Accepted

Validating a date with C# and ASP.NET Core 3.1

You could easily turn your method into a one-liner expression-bodied method with a few tricks: use the _ discard variable instead of the explicit ...
Jesse C. Slicer's user avatar
5 votes

How to avoid null Values in a .NET 6+ ASP.NET project

You're asking a debatable question as all approaches are valid and commonly used. It's a matter of which approach that you see is more suitable to your current codebase. Your goal should be to ...
iSR5's user avatar
  • 5,508
4 votes

Code Behind to manage AD users for a CRM system

Do NOT use Hungarian notation: bAccionOk, sPassword,... Do NOT use non-alphanumeric characters: ...
BCdotWEB's user avatar
  • 11.2k
4 votes
Accepted

Using Identity to create user administration page

Let's take about the ManageViewModel for a moment, because it has a lot of things you can do better. ...
Der Kommissar's user avatar
4 votes
Accepted

Filtering ASP.NET membership roles without the default attributes

public abstract class BaseController : Controller { public MasterDbContext Context { get; } = new MasterDbContext(); } I really don't like this. Every single ...
Mathieu Guindon's user avatar
4 votes

Log Visitor Count in Asp.net MVC

First of all I'd make code in Application_BeginRequest little bit more self-explicative: ...
Adriano Repetti's user avatar
4 votes
Accepted

Adding data to database using asp.net and sql-server

I would personally encapsulate your instantiation of MusicStoreDBEntities in a using statement so that the database connection is properly closed and disposed of. <...
Sean T's user avatar
  • 181
4 votes
Accepted

Adding data to database using ASP.net and SQL-server part 2

Coding/naming conventions: All the information about this can be found in folllowing article: Naming Guidelines. Straight from the documentation: To differentiate words in an identifier, capitalize ...
Abbas's user avatar
  • 5,563
4 votes
Accepted

Query URL parameters in downloading pictures from network cameras

Is my code readable enough? Unfortunatelly there is no objective answer to this question. Whether code is readable is mainly a personal opinion. I think you code isn't readable because it calls a lot ...
t3chb0t's user avatar
  • 44.3k
4 votes
Accepted

Update SQL database, similar-but-different queries for each month

There are two main problems with this: Firstly, as you've identified, your approach will involve a lot of repeated code. The only thing that changes for each of your SQL commands is the monthid field ...
Steven Eccles's user avatar
4 votes
Accepted

IsDatabaseUp returns true or throws exception

The naming convention Is… implies that the function is a predicate, returning either true or false. If you wanted to throw an exception when the database is down, ...
200_success's user avatar
4 votes

UserStore implementation for two databases

Don't Repeat Yourself. That is a common theme in Programming, I found a place where you can DRY out your code a little bit by extracting a return statement from ...
Malachi's user avatar
  • 28.7k
4 votes
Accepted

Convert IEnumerable<Reads> to CSV

I modified the formatting part for better readability and maintainability, at the cost of lower performance: ...
Xiaoy312's user avatar
  • 3,136
4 votes
Accepted

Async await multiple API calls

The idea about using Task.WhenAll is a good start as it could help with running then in parallel. Take a look at the following refactor ...
Nkosi's user avatar
  • 3,246
4 votes

Subscribe to Event form one service to another

in your case I would try to avoid subscribing to events as this couples the projects and references and prevents the garbage collector to clean up the unused service. if you are creating new services ...
Mightee's user avatar
  • 141
4 votes
Accepted

ASP.NET Core 3.1 AddHttpClient call that includes a call to the database

No need to manually create the DbContext. Since you have already registered it with the service collection, resolve it as needed. AddHttpClient has an overload ...
Nkosi's user avatar
  • 3,246
4 votes

ASP.NET Core 3.1 AddHttpClient call that includes a call to the database

Let me reflect to your other question, which is related to the good old ServicePointManager. In the early versions of .NET Core they tried to get rid of the ...
Peter Csala's user avatar
  • 9,486
4 votes

C# Convert BLOB to jpg, resize, then back to BLOB

Consider not using System.Drawing to manipulate images in ASP.NET: Classes within the System.Drawing namespace are not supported for use within a Windows or ASP.NET service. Attempting to use these ...
Johnbot's user avatar
  • 3,004

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