Teemablogi sissekanded

20.08.2020

How to log NHibernate SQL to ASP.NET Core loggers

Logging down SQL created by ORM is useful when debugging new features of application. SQL logging in NHibernate is a little bit tricky and not so straightforward as it is with Entity Framework Core. This blog post demonstrates how to log SQL created by NHibernate to ASP. NET Core logger using NHibernate interceptor. NB! In this post I will extend some parts of code shown in my blog post NHibernate on ASP. NET Core. 06:01 20.08.2020 kanalilt DT blogi 2

18.08.2020

Using Structuremap in legacy ASP. NET MVC applications.

Dependency Injection (DI) was also supported by classic ASP. NET MVC but there was no framework-level dependency injection like in ASP. NET Core. In this blog post I will show how to use Structuremap for dependency injection in ASP. NET MVC applications and how to resolve dependencies using built-in components in classes that doesn’t support dependency injection. Legacy warning! The code here and solutions are for classic ASP. NET MVC. 08:23 18.08.2020 kanalilt DT blogi 2

07.08.2020

Building ASP. NET Core applications on Visual Studio Codespaces and Visual Studio Code.

On the search for running development environments on cloud I stumbled upon service calles Visual Studio Codespaces. It’s nice service that moves development and debugging workloads to cloud and it makes it possible to use lightweight machines like tablets and hybrids for development. Here’s my overview of how to build ASP. NET Core web applications on codespaces and Visual Studio Code. 09:20 07.08.2020 kanalilt DT blogi 2

03.08.2020

Surface Go 2 review

Recently I bought Surface Go 2 tablet with Intel M3 CPU and LTE. Surface Go 2 is hybrid device being either tablet or small laptop. It is lightweight and therefore not the option for resource demanding workloads. Consider it more as an complementary device that is hyper-portable and supports you well if you are moving around. But Surface Go 2 is not yet another tablet – it’s more. 22:30 03.08.2020 kanalilt DT blogi 2

01.08.2020

IIS Express error: Failed to register URL for site.

A little surprise during COVID-19 time coding. I cloned repo to my dev box, opened it in Visual Studio and hit F5. IIS Express starts and browser opens but it shows just error about site to be unreachable. After almost getting grey hair I found out what’s wrong. Here’s the solution. It wasn’t any of the classic problems. Classic ones have one of these solutions: Open solution in Windows Explorer, close Visual Studio and delete . vs folder. 07:50 01.08.2020 kanalilt DT blogi 2

22.05.2020

Logging to Notepad window from ASP.NET Core

Something funny to end this week. When checking my Twitter feeds I found a kinky tweet about logging . NET Core messages to Notepad window. Yes, you heard right – . NET Core logger for Notepad. It’s not real, you want to say, but it is. And here’s how it works :) The story of Notepad. Extensions. Logging When checking Twitter I found a funny tweet by @yaakov_h where he announced NuGet package for. 05:53 22.05.2020 kanalilt DT blogi 2

21.05.2020

Introducing Azure Static Web App service

During Build 2020 Microsoft announced preview of Azure Static Web App service – app hosting offering for static web applications built on JavaScript. Automatic deployments to production and staging environments are implemented as GitHub integrations. Although currently in public preview this service is easy to set up and getting started. It will probably be one of developers favorite service in near future. 06:57 21.05.2020 kanalilt DT blogi 2

20.05.2020

Xamarin Forms turns to . NET MAUI – single project and code-base dev experience.

Yesterday Microsoft announced . NET Multi-platform App UI (MAUI) – the effort to turn Xamarin Forms apps use single cross-platform code-base targeting multiple platforms. Demos from Build conference yesterday gave clear signal – it’s not just an experiment but real deal. They really had single project running on Windows desktop and iPhone. This blog post is short overview of what’s coming. 05:22 20.05.2020 kanalilt DT blogi 2

19.05.2020

Hosting WordPress behind Azure Front Door

During lockdown I tried out how Azure Front Door works. It is another member of Azure load balancers and traffic routers world but it is global and designed for web applications. My only interest was to see how it works and if it is just for commercial sites or does it also fit for private WordPress blogs like I have. It was interesting journey full of of surprises and here’s the overview of what I did and how things worked out. 06:34 19.05.2020 kanalilt DT blogi 2

14.05.2020

Using Dapper in ASP.NET Core applications

Times ago I blogged about micro ORM-s. I have been busy through all Covid-19 times learning technical side of DDD and during that I met again my old friend Dapper. There are applications where Dapper is used to query read-only data without overhead coming with ORM-s. Also there are simple applications where for one or another reason developers decided to keep as close to raw SQL as possible. 10:39 14.05.2020 kanalilt DT blogi 2

25.03.2020

Optimize database traffic with future results in NHibernate

One nice feature that NHibernate has is future results. It is technically a capability to put queries on hold until data is actually asked. When data is asked from one delayed query then all queries are sent to database server as one batch and results are read also as one batch of multiple result sets. This blog post explains how to use future results with NHibernate. 08:13 25.03.2020 kanalilt DT blogi 2

24.03.2020

Displaying enum as select list in ASP.NET Core

Some properties of model classes come as enums and we want to show enum values in select list when edit form is opened. Sometimes we want enum element names but sometimes we want to use custom names or even translations. his blog post demonstrates how to get enum element names to select list on ASP. NET Core. Let’s suppose we have customer entity that has customer type property defined as enum. 12:41 24.03.2020 kanalilt DT blogi 2

20.03.2020

EF Core 5. 0: Using ToQueryString() method to translate LINQ query to SQL.

Entity Framework Core 5. 0 comes with SQL-based brother to ToString() method for LINQ-queries. This method is called ToQueryString() and it returns provider-specific SQL without connecting to database server. In some means it’s similar to ToTraceString() method of Entity Framework. This blog post shows how ToQueryString() method works. NB! At the time of writing this post . NET Core 5. 0 and EF Core 5. 07:15 20.03.2020 kanalilt DT blogi 2

18.03.2020

Using query strings in ASP.NET Core unit tests

Using query string in controller unit tests is actually easy until we don’t need anything more advanced. We can buld up a string with query parameters and go with it. But what if things get more complex and we need encoding or multiple values? Here’s how to build safe query string for ASP. NET COre controller unit tests. NB! It is recommended to use action method arguments instead of request query parameters in your controllers. 06:37 18.03.2020 kanalilt DT blogi 2

10.03.2020

Updating SQL Azure database using Visual Studio database project and Azure DevOps

Visual Studio database projects have been one of my important tools since Visual Studio 2010. Database projects were not easy to use with build servers ten years ago. Today things are different. It’s super easy to use database projects to update staging and live databases from Azure build and release pipelines. This blog post shows how to do it. 08:00 10.03.2020 kanalilt DT blogi 2

04.03.2020

Creating storage accounts and blob containers using Azure fluent API-s

Using Azure fluent API-s it is easy to create storage accounts and blob containers. After experimenting with fluent API of Azure storage I found it to be good match for multitenant web applications where tenant files are held on Azure blob storage. I was surprised how clean and short code I got using fluent API. Here’s my overview of fluent API for Azure storage with some code samples I wrote. 07:28 04.03.2020 kanalilt DT blogi 2

03.03.2020

MSSQL data and log files on Azure blob storage

I discovered lately one killer feature of SQL Server – keeping data and log files on Azure blob storage. There are scenarios where we may want to go with blob storage instead of buying and building up our own stable and reliable storage. This blog post introduces how MSSQL data and log files work on Azure blob storage. 09:52 03.03.2020 kanalilt DT blogi 2

28.02.2020

Using data from MSSQL linked server with EF Core

My previous blog post Querying MySQL from SQL Server using linked server introduced how to link MySQL database to MSSQL and how to write queries that gather data from local and linked server. This blog post demonstrates how to get data mixed from those sources to Entity Framework Core. Using data from MSSQL linked servers Linked servers are not directly supported by Entity Framework Core at LINQ level. 00:39 28.02.2020 kanalilt DT blogi 2

06.02.2020

Querying MySQL from SQL Server using linked server

SQL Server has interesting feature calles Linked Servers. It’s about linking other databases to SQL Server and using their data like it’s local. There are many powerful open-source systems written on PHP and they are mostly using MySQL as database. This blog post shows how to link MySQL database to SQL Server and how to use linked server in SQL queries. 06:40 06.02.2020 kanalilt DT blogi 2

03.02.2020

Implementing repository querying interface in EF Core DbContext

My last bold statement was that we don’t need custom unit of work and repository classes with Entity Framework Core. One issue remained unsolved and it was querying part of repositories (yeah, those custom querying methods). After some experiments to get querying interface of repositories to DbContext I worked out something that I kind of like. I managed to make DbContext to work like classic unit of work that hosts repository instances. 07:00 03.02.2020 kanalilt DT blogi 2