FluentValidation modify error message in Must function

Inside class that is responsible for validation I have simple rule: ``` RuleFor(u => u.Id) .Cascade(CascadeMode.StopOnFirstFailure) .NotEmpty().WithMessage("Id is required") .Must(Validat...

19 Jul at 09:32

Why can arrays not be trimmed?

On the MSDN Documentation site it says the following about the `Array.Resize` method: > If newSize is greater than the Length of the old array, a new array is allocated and all the elements are copied...

20 Jun at 09:12

The ADO.NET provider with invariant name 'MySql.Data.MySqlClient' is either not registered in the machine or application config file

I have an asp.net solution using entity framework 6 to mysql server. now I have to work on that solution on a new machine, but I have some problems: 1) when building the solution I get error: []...

Cast from IEnumerable to IEnumerable<object>

I prefer to use `IEnumerable<object>`, for LINQ extension methods are defined on it, not `IEnumerable`, so that I can use, for example, `range.Skip(2)`. However, I also prefer to use `IEnumerable`, fo...

SignInManager,what it is and how,when to use?

I am exploring SignInManager class. But the information given on MSDN is very useless. It only tells what are the methods and properties provided. What I am looking for is, 1. What is SignInManager? ...

C# - Downloading from Google Drive in byte chunks

I'm currently developing for an environment that has poor network connectivity. My application helps to automatically download required Google Drive files for users. It works reasonably well for small...

19 Jul at 04:30

How to Logout of Owin Providers?

I am following [this tutorial](https://dzone.com/articles/using-owin-external-login) yet it does not tell you how to logout. I tried to do ``` Request.GetOwinContext().Authentication.SignOut(Microso...

21 Jul at 16:30

formGroup expects a FormGroup instance

I have an Angular 2 RC4 basic form example on Plunkr that appears to throw the following error (In Chrome DEV console) Here's the plunkr [https://plnkr.co/edit/GtPDxw?p=preview](https://plnkr.co/edi...

Getting all types that implement an interface in .NET Core

Using reflection, How can I get all types that implement some specific interface in ? I have noticed that the methods usable in .NET 4.6 are not available anymore. For example, this code doesn't work...

18 Jul at 18:10

How to get input text value on click in ReactJS

I am learning ReactJS and I want to understand how to get the input text values in ReactJS using simple onclick event. I have followed there tutorial and although i am able to get the parameter of tex...

18 Jul at 18:3

How do I disable a test using pytest?

Let's say I have a bunch of tests: ``` def test_func_one(): ... def test_func_two(): ... def test_func_three(): ... ``` Is there a decorator or something similar that I could add to the...

8 Jul at 22:24

Difference between decimal.Round and Math.Round

What is the difference between Math.Round and decimal.Round functions in C# ?

18 Jul at 17:28

HttpClient: The uri string is too long

Given the following attempt to post data to a web service that generates PDF files, [PDF rocket](https://www.html2pdfrocket.com/) (). I get the error `POST` ``` using (var client = new HttpClient()...

19 Jul at 07:51

How do you unit test ASP.NET Core MVC Controllers that return anonymous objects?

I'm having trouble unit testing ASP.NET Core MVC controllers that return anonymous objects. The unit testing is set up in a separate project and calls the controller methods from the main project dire...

How to get cookie in ServiceStack

I have been trying to read a cookie in servicestack but get > "The type 'Cookie' is defined in an assembly that is not referenced. You must add a reference to assembly ..." I have alredy added th...

18 Jul at 13:38

What does {{{0}}} on string.Format do?

In the namespace `MS.Internal`, there is a class named `NamedObject`. It has a weird block of code: ``` public override string ToString() { if (_name[0] != '{') { // lazily add {} around the...

20 Jul at 06:39

Enable-Migrations Exception calling "SetData" with "2" argument(s)

I created a library based on .NET 4.6.2 version. To the library, I've added the EntityFramework version 6.1.3 package. I created a model as follow ``` using System; using System.ComponentModel.Data...

18 Jul at 12:56

proper way to sign .net core assembly

I'm trying to sign a .net core lib, and I'm just not sure if I did everything correctly 1) using VS Command Promp I called `sn -k mykey.snk` 2) copied `mykey.snk` to myproject folder 3) in `project.js...

30 Aug at 07:15

ServiceStack.Redis: "Unable to Connect: sPort: 0" and Unable to cast object of type 'System.Byte[]' to type 'System.Object[]'

I have a test harness that repeatedly gets and sets DateTime objects so we can test fail-over of our new Redis Sentinel deployment. I have added my license key to the static constructor of the calli...

Why is EF generating SQL queries with unnecessary null-checks?

I came across an issue with EF creating terrible queries when searching on a string field. Its produced a query in the style of lazy programmers to encompass null checking which forces the whole index...

18 Jul at 12:20

Why does upcasting IDictionary<TKey, TValue> to IEnumerable<object> fail?

See the following code snippet: ``` (IEnumerable<object>)new Dictionary<string, string>() ``` The above cast will throw an invalid cast exception. Actually, `IDictionary<TKey, TValue>` also indire...

18 Jul at 15:8

Toggle switch control in Windows Forms

I am designing a control using `CheckBox`, but currently my control only draws a circle. How can I draw round shapes like the below image and how can I change the location of the circle based on the ...

How to retrieve a single value from the database using Dapper

I'm using Dapper and trying to retrieve a short from the database and would like to do this without grabbing it from a collection. I've got the following code, which doesn't work because `QueryAsync<...

18 Jul at 07:3

Difference between forward slash (/) and backslash (\) in file path

I was wondering about the difference between `\` and `/` in file paths. I have noticed that sometimes a path contains `/`and sometimes it is with `\`. It would be great if anyone can explain when to ...

2 Jul at 20:52

Setting selected option in laravel form

I need to give selected value like this html: ``` <select name="myselect" id="myselect"> <option value="1">Item 1</option> <option value="2" selected='selected'>Item 2</option> ``` how can I ac...

29 Jul at 12:23