How to execute SqlQuery with Entity Framework Core 2.1?

In Entity Framework 6, I can execute a raw SQL query on the database using the following command: ``` IEnumerable<string> Contact.Database.SqlQuery<string>("SELECT a.title FROM a JOIN b ON b.Id = a.a...

Suppress a warning for all projects in Visual Studio

I've seen answers showing how to suppress a warning for a specific line of code or for a specific project. I don't want that. I want to suppress a specific warning for of my projects. (If it matter...

Setting UIaccess altering behavior of ShowDialog

I have a login prompt as part of a WPF application - when the user enters an incorrect password, a new modal dialog window appears informing them that their password is incorrect. This modal dialog is...

30 Sep at 15:19

Performance Metrics/Diagnostics of .NET Tasks

Is there a way to get data out from .NET about the number of (C# 5 or newer, so post-async/await) Tasks pending execution, and similar metrics, for use in diagnosing issues happening to production ser...

17 May at 18:28

Injecting Simple Injector components into IHostedService with ASP.NET Core 2.0

In ASP.NET Core 2.0, there is a way to add background tasks by implementing the `IHostedService` interface (see [https://learn.microsoft.com/en-us/aspnet/core/fundamentals/hosted-services?view=aspnetc...

How to optimize WCF CreateFactory in System.ServiceModel.ChannelFactory?

My current implementation is utilizing the ClientBase class to create a channel for WCF calls made to a third party API. This third party API requires a X509Certificate2 certificate as well as ClientC...

Autofac - SingleInstance HttpClient

Have read in various places that HttpClient should be reused rather than a new instance every time. [https://aspnetmonsters.com/2016/08/2016-08-27-httpclientwrong/](https://aspnetmonsters.com/2016/08...

17 May at 14:49

Hyperlinks without underline in RichTextBox on Windows 10 1803

I'm displaying RTF document in `RichTextBox` ("upgraded" to `RichEdit50W`). Keywords in the document are linked to a webpage using a syntax: ``` {\field{\*\fldinst{HYPERLINK ""https://www.example.com...

17 May at 13:17

Why does an implicit conversion operator from <T> to <U> accept <T?>?

This is a weird behaviour that I cannot make sense of. In my example I have a class `Sample<T>` and an implicit conversion operator from `T` to `Sample<T>`. ``` private class Sample<T> { public r...

ServiceStack Razor not finding right view

I have a [ServiceStack](http://www.servicestack.net) site that uses [ServiceStack.Razor](http://razor.servicestack.net) without issue. I upgraded from 4.0.50 to 5.1.0 - with no other substantive chan...

16 May at 20:5

1-length string comparison gives different result than character comparison... why?

I am quite new in C# and I found something unexpected in string comparison which I don't really understand. Can someone please explain me why the comparison between characters gave the opposite resu...

16 May at 16:54

How to create a table corresponding to enum in EF Core Code First?

How would one turn the enums used in an EF Core database context into lookup tables and add the relevant foreign keys? --- - [EF5 Code First Enums and Lookup Tables](https://stackoverflow.com/q/1...

16 May at 15:59

Check if value is 0 with extension method

I have an extension method which looks like ``` public static T ThrowIfObjectIsNull<T>(this T argument) where T : class { if (argument == null) throw new ArgumentNullException(nameof(argumen...

16 May at 20:41

'4' and '4' clash in primary key but not in filesystem

There is DataTable with primary key to store information about files. There happen to be 2 files which differ in names with symbols '4' and '4' (0xff14, a "Fullwidth Digit Four" symbol). The DataTable...

16 May at 13:11

ReadAsMultipartAsync equvialent in .NET core 2

I'am rewriting a .net 4.5 application to aspnet core 2.0 and I have a method that i have some problem updating: ``` [HttpPut] [Route("api/files/{id}")] public async Task<Person> Put(int id) ...

16 May at 10:48

Xamarin.Forms Animation on click Button (Flash background)

I want to implement a dialpad on my form. Now, in my XAML I am testing a button: XAML ``` <?xml version="1.0" encoding="UTF-8"?> <ContentPage xmlns="http://xamarin.com/schemas/2014/forms" x...

20 May at 20:6

Error combining 'if' statements that null-checks and Pattern Matches

The following works as expected: ``` dynamic foo = GetFoo(); if (foo != null) { if (foo is Foo i) { Console.WriteLine(i.Bar); } } ``` but if I combine the if statements like so...

11 Apr at 16:12

How to handle enum as string binding failure when enum value does not parse

In our ASP.net Core Web API application I am looking for a way to catch binding errors when my controller method accepts a complex object which has an ENUM property when ENUMs are de/serialized as str...

.NET Core 2.0 Regex Timeout deadlocking

I have a .NET Core 2.0 application where I iterate over many files (600,000) of varying sizes (220GB total). I enumerate them using ``` new DirectoryInfo(TargetPath) .EnumerateFiles("*.*", Searc...

16 May at 18:37

C# 7.3 Enum constraint: Why can't I use the nullable enum?

Now that we have enum constraint, why doesn't compiler allow me to write this code? ``` public static TResult? ToEnum<TResult>(this String value, TResult? defaultValue) where TResult : Enum { ...

15 May at 13:35

Automate CRUD creation in a layered architecture under .NET Core

I'm working in a new project under a typical three layer architecture: `business`, `data` and `client` using Angular as a front. In this project we will have a repetitive task that we want to automat...

17 May at 11:44

Migrate existing Microsoft.AspNet.Identity DB (EF 6) to Microsoft.AspNetCore.Identity (EF Core)

I am working on an application (APS.net MVC) which uses . Now I want to revamp my application to APS.net Core which uses . But those two has some differences in each model. Is there any direct way to ...

What does the .dtbcache file do?

I have a C# WinForms project, which I am working on in Visual Studio 2017 (although it was originally created in the 2015 version). I don't recall having done anything special, but it has added a fi...

Azure Function, EF Core, Can't load ComponentModel.Annotations 4.2.0.0

I have created several .Net Standard 2.0 libraries, tested the execution via a console application, as well as several tests - all is good. Move over to azure function, and get the following run-time...

How to increase timeout setting in ASP.NET Core SignalR v2.1?

I'm trying out the latest SignalR on ASP.NET Core 2.1. I have the basic app working but it times out pretty soon right now. I see this error - > Error: Connection disconnected with error 'Error: Ser...