Use a custom function when mapping one property to another with Automapper
Automapper is a handful tool for mapping the properties of two different type objects together. Such mappings are very common when you are dealing with a multi-tier architecture in your program. For example you want to map the entity object, which contains data from the database, with the UI-model object of your WebApi action.
For basic mapping examples refer to the Automapper documentation. In this article we will consider the following advanced example:
Your entity model contains a property with a non-serialized string that you store in a table of your database
Based on some condition checking, you want to or do not want to deserialize this string and store it into a property of different type of your UI-model object
For that you need a mapping between two properties of different type and also a function that runs every time to do this transformation:
A possible reason for the .NET MVC "The view XXXX or its master was not found" error
“The view XXXX or its master was not found” error looks like that:
"The view 'XXXX' or its master was not found or no view engine supports the searched locations.
The following locations were searched:
~/Areas/XXXX/Views/XXXX/XXXX.cshtml
~/Areas/XXXX/Views/XXXX/XXXX.vbhtml
~/Areas/XXXX/Views/Shared/XXXX.cshtml
~/Areas/XXXX/Views/Shared/XXXX.vbhtml
~/Views/XXXX/XXXX.cshtml
~/Views/XXXX/XXXX.vbhtml
~/Views/Shared/XXXX.cshtml
~/Views/Shared/XXXX.vbhtml"
and I recently had to deal with it, although I was 100% sure that my view was in the right place inside my MVC project.
Run your Load Tests against multiple server environments, like localhost, development or integration
Load Tests help us identify bottlenecks in our application and can answer with high precision how many users our infrastructure can support in a given time. In a previous article I gave you some tips for using the Load Tests from Visual Studio in a more efficient way.
Today I would like to show you how you can run the same load tests against different server environments, for example on your localhost machine and on the integration server, before deploying a change into the production.
How to find the connection string of your LocalDB database in Visual Studio
Today while I was developing a .NET Core example for testing Dapper against my LocalDB tables, I had to define the connection string so that I can run queries in my code against the database. If I was to use Entity Framework, then the connection string would be scaffolded for me, but now I have to find it on my own.