Skip to main content
Share Your Experience: Take the 2024 Developer Survey
8 votes

Recording error messages from an exception

In C# 6 or later you can write it in a single line of code using the null conditional operator (?.) and the null coalescing operator (...
Zohar Peled's user avatar
6 votes
Accepted

Configure AspNet.Identity to allow for either username OR email address on login

I know this is an old ticket, but I think I might have an approach that uses only one round trip to the database. ...
user1533613's user avatar
6 votes

Recording error messages from an exception

Assuming you have at least c# 6 (and thus, the null propagation operator), you can simplify it like this: ...
zaitsman's user avatar
  • 161
3 votes
Accepted

Retrieving all institutions in a specified country

Country.Institutions should never return a null collection, and if it ever does, I'd prefer having a ...
Mathieu Guindon's user avatar
3 votes

Recording error messages from an exception

You can use GetBaseException to get the lowest level exception. ...
Mike Norgate's user avatar
2 votes

Web Api to upload excel file

Naming Convention current code is not using camelCase naming convention on local variables, and also is not given a good naming ...
iSR5's user avatar
  • 5,278
2 votes

Open closed principle in a method

Before reviewing micro-design we may focus on overall architecture. You already know that in future you will also need to read an Excel file, it may be a good moment to introduce an abstract base ...
Adriano Repetti's user avatar
2 votes
Accepted

Passing model to _layout.cshtml

Implemented a better design by converting the navigation section into a PartialView and converted UserViewModelBase and ...
niklodeon's user avatar
  • 193
2 votes

DbSet<T> IncludeAll method

Include uses when you want to include ICollection properties or not int, string, ...
Islam Alshiki's user avatar
2 votes
Accepted

Calling Web API from MVC generic way of approach

I agree as some others have said that in this case, having a layer between Angular and your API is simply bloat / overhead unless there are specific reasons for the extra abstraction. I understand ...
xDaevax's user avatar
  • 1,171
1 vote

Use of C# Razor Syntax in MVC.net view

I would argue that the code in the top should not be moved to Controller. This of course depends on how you define responsibilities for View, Controller and Model, but I would leave the code in the ...
Hekku2's user avatar
  • 151
1 vote

Calling Web API from MVC generic way of approach

The code described above could employ a generic method which could take all the common and repetitive code and just take in the endpoint (e.g. "api/Roles") as a parameter. This could help to reduce ...
Geek's user avatar
  • 439
1 vote

DbSet<T> IncludeAll method

EF knows about all navigation properties. So, instead of using reflection and try to figure it out by myself, I can just ask the DbContext about navigation ...
Dejan's user avatar
  • 143

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