Teemablogi sissekanded

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. 09: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. 13: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. 08: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. 07: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. 09: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. 08: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. 10: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. 01: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. 07: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. 08:00 03.02.2020 kanalilt DT blogi 2

30.01.2020

Building experimental hybrid Blazor WebAssembly application

After getting done with Blazor desktop applications I tried to build kind of hybrid Blazor WebAssembly application that can run on desktop and in web equally. Although I failed to make it as one single application, I still got it work with a little different architecture. And what’s best – Blazor desktop applications run already now as self-contained executables. Here’s my experiment. 09:42 30.01.2020 kanalilt DT blogi 2

29.01.2020

Exploring WebWindow examples for Blazor on desktop

Blazor on desktop is one of latest hot topics and . NET Conf: Focus on Blazor only added more fuel to fire. Blazor seems to come everywhere and it’s unstoppable. One of interesting desktop experiments is WebWindow by Steve Sanderson. It’s cross-platform component to make Blazor WebAssembly applications run on desktop. Let’s take a closer look at WebWindow and Blazor on desktop. 09:16 29.01.2020 kanalilt DT blogi 2

27.01.2020

Start with Surface Duo development on preview emulator and SDK today

Surface Neo and Surface Duo are new devices by Microsoft, planned to launch for holidays season this year. Surface Neo runs Windows and Surface Duo is based on Android. For Surface Duo there’s already preview tooling and SDK available by Microsoft. Here’s the introduction to Surface Duo development, tools and patterns. With Surface Neo and Surface Duo Microsoft enters a era of hybrid devices. 08:10 27.01.2020 kanalilt DT blogi 2

23.01.2020

Creating subdomains to Azure DNS from ASP.NET Core

Multitenant wep applications detect current tenant usually by URL checking name of first level folder or subdomain. Usually tenants are defined by subdomain as it is easier to distribute them over data center, cloud services or hosting accounts. This blog post demonstrates how to build Azure DNS service client to create DNS records for multitenant application subdomains. 09:01 23.01.2020 kanalilt DT blogi 2

22.01.2020

Inject users and roles dynamically to ASP. NET Core integration tests.

After getting fake authenticated user to ASP. NET Core integration tests I made step further and introduced the way to use different user accounts. Using multiple users and roles instead of one test users is very common scenario in web applications. During my carreer I have seen only few business applications that doesn’t use different roles. This blog post demonstrates how to inject users dynamically to ASP. NET Core integration tests. 08:00 22.01.2020 kanalilt DT blogi 2

20.01.2020

Behind the compiler: 20 examples of C# code before and after compiling

Over years I have written many blog posts about C# and . NET that demonstrate also how things work internally and what C# compiler produces from the code we write. I have called these chapters usually as “Behind the compiler”. This post is growing list of my writings covering interesting findings about C# compiler work. Behind the compiler posts Throw expressions in C# 7. 0 Using-declarations in C# 8. 08:00 20.01.2020 kanalilt DT blogi 2

15.01.2020

Announcements from .NET Conf: Focus on Blazor

Microsoft made very interesting announcements at . NET Conf: Focus on Blazor online conference. There are many great things are happening and Blazor is also making a fast progress on finding its way to mobile and desktop. Here’s the short overview of what’s happening and what’s coming next. Blazor WebAssembly new features for May Features of Blazor WebAssembly (aka client-side Blazor until now) were announced by Dan Roth: Runs on. 06:41 15.01.2020 kanalilt DT blogi 2

14.01.2020

Create fake user for ASP. NET Core integration tests.

After getting done with fake users for ASP. NET Core controller unit tests I wanted to make fake users available also in integration tests. It took some inventing and hacking but I made it work. This blog post shows you how to create fake users for ASP. NET Core integration tests and write effective extension methods to keep integration tests shorter. Source code available! Thin and clean demo solution with ASP. 07:41 14.01.2020 kanalilt DT blogi 2

11.01.2020

Create fake user for ASP.NET Core controller tests

I think most of ASP. NET Core applications have authentication enabled. When writing unit tests for controllers we have one set of tests that need authenticated user and other set of tests that need anonymous user. Faking User property of controller is a little bit tricky. This blog post shows how to do it. Source code available! Source code and sample ASP. 15:50 11.01.2020 kanalilt DT blogi 2

10.01.2020

Embedded Power BI reports with ASP.NET Core

Last year I had some projects where I had to embed Power BI reports to ASP. NET Core applications. There were easy cases that solved practically with copy-paste but I also had more complex situation where server-side code was needed because application uses custom authentication instead of Azure AD. This blog post covers both scenarios for embedding Power BI reports to ASP. NET Core applications. 08:17 10.01.2020 kanalilt DT blogi 2