Teemablogi sissekanded

08.01.2020

DataSet and DataTable based ad-hoc reporting with ASP.

In one of my projects I have some ASP. NET Core views that display multiple tables with reporting data. Data comes from SQL Server views and stored procedures and these can be modified in database without deploying application to server again. I came out with very common solution in ASP. NET Core to solve this problem using raw SQL commands and shared views for DataTable and DataSet. Here’s what I did. 07:21 08.01.2020 kanalilt DT blogi 2

07.01.2020

Execute raw SQL commands in Entity Framework Core

I have never seen a real-life project where object-relational mapper generates 100% of needed SQL. There have always been those special cases when raw SQL commands are needed. In this post I will demonstrate how to run raw SQL commands in Entity Framework Commands and how to read data from database without DbSet and query types. 11:06 07.01.2020 kanalilt DT blogi 2

03.01.2020

Get notification to e-mail when I post something

First of all – thanks to all my blog readers to be here with me. Last year was the one where the most important metric of blogs – number of page views – made its yearly record and reached a million. What should I say? Thanks a million! As some of you have asked my for one feature my blog should have I’m glad to tell you it’s here – yes, you can get e-mail notifications about new posts published here. 14:08 03.01.2020 kanalilt DT blogi 2

02.01.2020

Using CSOM from Azure Functions

I got back to active SharePoint and CSOM development some months ago and first thing to do was to port bunch of workflows from in-prem SharePoint to cloud. Where I live we don’t usually have any simple workflows. Most of them need some backing code due to custom logic. So, my only option was to go with Microsoft Flow or Azure Logic Apps and Azure Functions. Here’s the project with one dummy function to get started. 11:13 02.01.2020 kanalilt DT blogi 2

30.12.2019

Copy production database to staging on Azure DevOps

I’m building build and release pipeline on Azure DevOps for one of my projects. We want to automate testing and deployments to staging environment. At staging environment we want to use copy of production database to make sure that testers are working with latest data. Here’s how to make Azure SQL database copy on Azure DevOps using Azure PowerShell. My scenario What I’m building is shown on the following image. 10:18 30.12.2019 kanalilt DT blogi 2

19.12.2019

Using nameof operator in C#

There’s one very useful and often overlooked operator in C#. It’s called nameof and its purpose is to return name of something. Although it is operator we can live without it may still commit to coding by pointing out some errors at compile time. Here’s how to use the nameof operator in practice. How nameof operator works? Nameof operator can return names of different code artifacts. 09:50 19.12.2019 kanalilt DT blogi 2

17.12.2019

Logging NHibernate SQL commands to debug window

I know there are advanced tools like SQL Server Profiler and NHibernate Profiler but often I want to see NHibernate queries just in debug window to have overview of what’s going on. It’s specially important when improving some legacy application where previous developers had not much idea how NHibernate works. Here’s the simple solution I’m using to get SQL generated by NHibernate to Visual Studio debug window. 07:53 17.12.2019 kanalilt DT blogi 2

11.12.2019

Using configurable composite command in multi-tenant ASP.

My previous posts about tenant-based dependency injection and using composite command in ASP. NET Core culminated with idea to use configurable composite commands in multi-tenant ASP. NET Core applications. Configurable composite commands make it easy to tweak save and update processes that contain multiple steps of what some can be custom and their activation is based on tenant configuration. Here’s how to build thost composite commands. 11:26 11.12.2019 kanalilt DT blogi 2

09.12.2019

Using Windows Forms DataGridView in .NET Core 3.1

Windows Forms is coming to . NET Core and last version of Visual Studio 2019 Preview comes with form designer built in. There are basic controls available in toolbox but not all out-of-box controls have made their way there. One of these is DataGridView. Although not shown in toolbox, DataGridView still works like expected. Here’s how I made it work. NB! Form Designer for. 09:53 09.12.2019 kanalilt DT blogi 2

02.12.2019

Tenant-based dependency injection in multi-tenant ASP.

One need in multitenant applications is injecting dependencies based on tenant configuration. It can be actually more complex as instances may need constructor parameters. Here is my example of dynamic injection of multiple file clients in ASP. NET Core multi-tenant web application. Source code available! Source code for all my ASP. 01:09 02.12.2019 kanalilt DT blogi 2

25.11.2019

Modeling people and organizations: Employees

Modeling employees seems to be easy when we get started but it quickly turns more complex than we first expect. Specially if we need good and flexible model we don’t have to replace time by time. This post is continuation to my writing Modeling people and organizations: Party generalization and it extends the previous model with support to employees. 10:21 25.11.2019 kanalilt DT blogi 2

19.11.2019

Readable fluent queries with Entity Framework Core

After my first experiments with Query Specification pattern on Entity Framework Core I came to interesting idea – why not using extension methods that wrap query specifications or add directly some more conditions to IQueryable<T> the way that queries are easy to read. Here’s my experiment and thoughts of fluent readable queries. Warning! This blog post covers my new experiments with readable fluent queries. 07:51 19.11.2019 kanalilt DT blogi 2

18.11.2019

Implementing Query Specification pattern in Entity Framework Core

My previous blog post No need for repositories and unit of work with Entity Framework Core showed how Repository and Unit of Work patterns are already implemented in Entity Framework Code (and NHibernate) and how we can use IDataContext generalization to get ORM-s behind same interface. As I’m still trying to find out what’s the best place where to isolate queries without exposing IQueryable I started playing with Query Specification pattern. 00:02 18.11.2019 kanalilt DT blogi 2

14.11.2019

No need for repositories and unit of work with Entity Framework Core

After working again on codebase where Entity Framework Core was used through repository and unit of work patterns I decided to write eye-opener post for next (and maybe even current and previous) generations about what Entity Framework has to offer in the light of these to patterns. In many cases we don’t have to move away from database context approach but stick with it even more than we first planned. 08:32 14.11.2019 kanalilt DT blogi 2

10.11.2019

Building gRPC service on ASP.NET Core

ASP. NET Core supports gRPC protocol that is about to replace legacy SOAP services with more performant and powerful protocol that is easier to use and support. This blog post shows how to build gRPC service and client on Visual Studio and ASP. NET Core. What is gRPC? gRPC is modern high performance communication framework for connected systems. By nature it is Remote Procedure Call (RPC) framework. 20:11 10.11.2019 kanalilt DT blogi 2

07.11.2019

Using composite command in ASP.NET Core

My introduction to composite command pattern was more theoretical and focused to high-level details. This blog post focuses on implementation details and introduces how to use composite command in ASP. NET Core to upload and process photos. Composite command pattern Composite command is mixed design pattern that is made up of command pattern and composite pattern. 10:45 07.11.2019 kanalilt DT blogi 2

06.11.2019

Data annotations object graph validation is coming to Blazor

Future versions of Blazor will support cascading data annotations support meaning that validation of child components is also supported. First experimental bits were released counted hours ago with . NET Core 3. 1 Preview 2. Here’s how object graph validation will work in Blazor. Building object graph My previous post about Blazor form validation introduced how validation is implemented for EditForm element used on Blazor pages. 11:27 06.11.2019 kanalilt DT blogi 2

03.11.2019

Building Blazor “Hello, Blinky” IoT application

I thought first my ASP. NET Core edition of Hello, Blinky will be my last Hello, Blinky for long time. But then something reminded me of Blazor and I thought  why not build Blazor edition of Hello, Blinky for Windows IoT Core and Raspberry Pi? After some hacking I made it work. Here’s my Hello, Blinky for Blazor. Who the hell is Hello, Blinky? Hello, Blinky is kind of Hello, World from Raspberry Pi and other microboards world. 10:14 03.11.2019 kanalilt DT blogi 2

31.10.2019

File uploads in ASP.NET Core

Just wrote down something I had to went through with students in one of my classes – making file uploads work in ASP. NET Core application. Here are samples of single and multiple file uploads using simple controller actions. Creating upload action and view I start with clean ASP. NET Core application and add Upload() action to HomeController. public IActionResult Upload(){ return View();} It’s empty and returns just view to upload files. 18:56 31.10.2019 kanalilt DT blogi 2

26.10.2019

Composite command pattern

I have previously blogged about command pattern and composite pattern. I had some projects where I succesfully mixed these two together to compose a composite command. It’s a construct to have a commands hierarchy we can execute with one shot. Why composite command? Composite command is mix of command and composite patterns and it forms command that consists of child commands that are executed once together. 10:08 26.10.2019 kanalilt DT blogi 2