My Blog

Sharing programming insights since 2015. 160 articles (and counting!) filled with real-world experience and practical tips.

    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:

    For that you need a mapping between two properties of different type and also a function that runs every time to do this transformation:

    Read the complete article

    Clone a Git repository from Azure DevOps to your local machine by using the command line

    In order to download and use a remote repository, which is stored in Azure DevOps, do the following two steps and you are good to go.

    Read the complete article

    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.

    Read the complete article

    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.

    Read the complete article

    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.

    Read the complete article