Skip to main content
7 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
7 votes

EventLogger for MVC application

Again enums should not have any prefix. Drop all those Enum_! You may like to take a look to .NET Naming Guidelines. Inside the class ...
Adriano Repetti's user avatar
7 votes
Accepted

DDD Architecture for an e-commerce website (uploading images)

Architecture DDD-wise : The most important thing about DDD is that the domain drives the design (so.. DDD). That means that when we look at your domain objects we should be able to understand the ...
IEatBagels's user avatar
  • 12.7k
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.7k
6 votes

Repository pattern with Unit of work using ADO.NET in C# to authenticate user from database

Side-effects On its own, this: ...
Reinderien's user avatar
  • 71.2k
5 votes

Apply Coupon Validation in Order

IsAppliedCouponValid() Don't omit braces although they might be optional. Omitting braces can lead to hidden and therfor hard to find bugs. The intermediate variables ...
Heslacher's user avatar
  • 51k
5 votes

DDD Architecture for an e-commerce website (uploading images)

at first I thought to write this as a comment, perhaps the comment would be a little to long… There are many things to consider here, not really inline with your question but perhaps you should ...
Walter Vehoeven's user avatar
5 votes

DDD Architecture for an e-commerce website (uploading images)

Review Modelling the domain is crucial when designing a multi-layered application. Your concerns about polutting the domain with file or web specific code is pivotal to make a clean, extensible, ...
dfhwze's user avatar
  • 14.2k
5 votes
Accepted

Creating a round robin MySQL connection manager

Aliveness issue As it is, your code does not perform the task you expect it to, because the LoadBalancer never reinstates "dead" connection pools. Notice that you only ever set ...
Vogel612's user avatar
  • 25.5k
5 votes

Repository pattern with Unit of work using ADO.NET in C# to authenticate user from database

Some quick remarks: epaperconnectionString doesn't follow the proper naming conventions for compound words. Also: why wouldn't you store all your configuration ...
BCdotWEB's user avatar
  • 11.4k
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

Common Implementation for Sending mail based on time

First of all you do not need to prefix all your enum with Enum_, the same way you do not do it with ...
Adriano Repetti's user avatar
4 votes
Accepted

HttpClient wrapper for simple calls with optional cert

As is this does not work because multiple requests will concurrently operate on the same variables (instance variables and HttpClient internal state as it is being configured). This is fairly easy to ...
usr's user avatar
  • 745
4 votes

Method GetById and SingleResult

[EnableQuery] and SingleResult does in fact return 404 OOTB, that is one of the key reasons for ...
Chris Schaller's user avatar
4 votes
Accepted

Extending IPrincipal.IsInRole()

IsInRole() I don't like how the method parameters are validated. IMO the null-propagation operator shouldn't be used for everything because it reduces the readability. Having a null-propagation ...
Heslacher's user avatar
  • 51k
4 votes
Accepted

Instantiating View Models using a static factory

That class can still be abstracted public interface IAdSummaryMapper { List<IAdSummary> MapAdSummaries(List<AdResult> esResults); } The search ...
Nkosi's user avatar
  • 3,296
4 votes

DDD Architecture for an e-commerce website (uploading images)

Thank you for an interesting question 😊 Here is the first part of the answer, I will publish more over the weekend at https://github.com/dmitrynogin/shopless. Let’s talk about storage access first. ...
Dmitry Nogin's user avatar
  • 6,131
4 votes
Accepted

ASP.NET MVC 5, EF 6 filter performance

It might be boring to hear it again, but I have to ask :) Why do you think your application need performance optimisations? Is your bottle neck in these parts of code which you provided? Maybe problem ...
Karol Miszczyk's user avatar
4 votes

Creating a round robin MySQL connection manager

MySQLConnectionManager DbConnection GetDbConnection() and List<string> SplitMultiHostConnectionString() Whenever you ...
Heslacher's user avatar
  • 51k
4 votes
Accepted

ASP.NET Web API for currency

GetCurrencies I would suggest to create a named/typed HttpClient with the proxy handler to make it reusable In this SO topic ...
Peter Csala's user avatar
  • 10.8k
3 votes
Accepted

Performance concerns for synchronous action methods

How large does a database have to be with how many calls to it before the async overhead is worth it? You will have benefits immediately. SQL Server is a multi-user database and even for small/simple/...
Adriano Repetti's user avatar
3 votes
Accepted

Creating a list with nested lists

You have written about 10 times as much code as needed to create your collection of CategoryModel You can greatly simplify this by using linq queries, and gain some ...
Stephen Muecke's user avatar
3 votes

Authorization - Create and unlock a User

Some quick remarks: Don't name things "class", e.g. HelperClass. Don't use Hungarian notation and give your variables meaningful names: ...
BCdotWEB's user avatar
  • 11.4k
3 votes
Accepted

Use SemaphoreSlim to control access to a resource

Review I would say, KISS (keep it stupid simple). Try going for a single lock and benchmark both normal expected thoughput and peek scenarios. If you would manage with this setup, you're done. In ...
dfhwze's user avatar
  • 14.2k
3 votes

Creating a ModelBinder to Sanitize user input in HTML format

Developer gone 'rogue' I am not entirely happy with this code. The reason is, in the future, a developer may forget that HtmlSanitizerFactory should be used for instantiating HtmlSanitizer... so ...
dfhwze's user avatar
  • 14.2k
3 votes
Accepted

Decoupling of validation and data access in ASP.NET

I guess you'll find a lot of redundancy in the code since its been held by the controllers. Your idea of making a service is a good idea, you may need to add different services, but at the end you'...
iSR5's user avatar
  • 6,383
3 votes

c# IEnumerable Update object

Are you using a ORM like Entity framework? If so use navigation properties and let it resolve the dependencies for you. UnitOfWork.Save(); This is a bad design ...
Anders's user avatar
  • 690
3 votes
Accepted

c# IEnumerable Update object

I like the suggestions to let SQL do the foreign key cascading for you. Also, have you considered generating the id's outside the system (e.g. Guid.NewGuid()) and ...
Aron's user avatar
  • 487
3 votes
Accepted

Detecting supported browsers in ASP.NET MVC (Server side vs. Client side)

I always go with the version that would be a best fit to the project. This means, you need to consider the overall project coding syntax, and how much code in the client side, to know where to focus ...
iSR5's user avatar
  • 6,383
3 votes
Accepted

Building ASP.Net control from JSON Data

As was mentioned in the comments, there is no need in using Where LINQ since FirstOrDefault accepts a predicate that can be ...
QuasiStellar's user avatar
  • 2,327

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