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 ...
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 ...
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 ...
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
Repository pattern with Unit of work using ADO.NET in C# to authenticate user from database
Side-effects
On its own, this:
...
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 ...
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 ...
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, ...
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 ...
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 ...
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
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 ...
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 ...
4
votes
Method GetById and SingleResult
[EnableQuery] and SingleResult does in fact return 404 OOTB, that is one of the key reasons for ...
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 ...
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 ...
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. ...
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 ...
4
votes
Creating a round robin MySQL connection manager
MySQLConnectionManager
DbConnection GetDbConnection() and List<string> SplitMultiHostConnectionString()
Whenever you ...
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 ...
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/...
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 ...
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: ...
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 ...
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 ...
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'...
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 ...
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 ...
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 ...
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 ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
asp.net-mvc × 233c# × 224
entity-framework × 40
asp.net × 28
mvc × 18
asp.net-web-api × 16
razor × 14
javascript × 13
design-patterns × 13
linq × 12
unit-testing × 11
dependency-injection × 11
performance × 10
asp.net-mvc-5 × 10
beginner × 9
jquery × 8
.net × 7
repository × 7
html × 6
authorization × 6
security × 5
error-handling × 5
ajax × 5
asp.net-core × 5
object-oriented × 4