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 ...
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
...
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)...
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 ...
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 ...
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 ...
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 ...
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: ...
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 ...
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 ...
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:
...
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 ...
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 ...
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: ...
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.
...
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 ...
4
votes
Log Visitor Count in Asp.net MVC
First of all I'd make code in Application_BeginRequest little bit more self-explicative:
...
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.
<...
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 ...
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 ...
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 ...
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, ...
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 ...
4
votes
Accepted
Convert IEnumerable<Reads> to CSV
I modified the formatting part for better readability and maintainability, at the cost of lower performance:
...
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
...
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 ...
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 ...
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 ...
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 ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
asp.net × 455c# × 395
.net × 45
entity-framework × 37
sql × 32
vb.net × 29
asp.net-mvc × 28
javascript × 25
mvc × 23
performance × 21
asp.net-mvc-4 × 19
sql-server × 18
jquery × 16
linq × 14
asp.net-core × 14
asp.net-web-api × 14
beginner × 13
html × 11
design-patterns × 11
security × 10
validation × 10
asp.net-mvc-3 × 10
database × 9
object-oriented × 8
authentication × 8