Why is typeA == typeB slower than typeA == typeof(TypeB)?
I've been optimising/benchmarking some code recently and came across this method: ``` public void SomeMethod(Type messageType) { if (messageType == typeof(BroadcastMessage)) { // ... ...
React.useState does not reload state from props
I'm expecting state to reload on props change, but this does not work and `user` variable is not updated on next `useState` call, what is wrong? ``` function Avatar(props) { const [user, setUser] =...
- Modified
- 14 Nov at 02:31
Global exception handling in Xamarin.Forms
Is there a way to handle exceptions at a global level in a Xamarin.Forms app? Currently my app has a login page which has a button "Throw Exception" button bound to the "Exception_Clicked" method. `...
- Modified
- 25 Feb at 12:11
ServiceStack ORMLite JoinAlias on a Where clause
I'm trying to add a Where clause to a table joined with a JoinAlias, but there doesn't appear to be a way to specify the JoinAlias on the where clause. I'm trying to join to the same table multiple t...
- Modified
- 25 Feb at 03:45
OrderBy in Include child using EF Core
In my .NET Core / EF Core application I have a model with a nested list of child objects. When I retrieve an instance, I need the nested list to be ordered by one of the child's properties. What is t...
- Modified
- 1 Mar at 02:16
Azure Function, returning status code + JSON, without defining return in every part of logic
I have an Azure Function 2.x that reside on a static class that looks like this ``` [FunctionName("Register")] public static async Task<IActionResult> Run([HttpTrigger(AuthorizationLevel.Anonymous, "...
- Modified
- 25 Feb at 10:23
Force Servicestack to delimit fields when producing CSV
I'm using Servicestack to produce CSV. The data contains mobile (cell) phone numbers. These start with a leading zero e.g. 04053333888. My problem is the consumers open this file in Excel, which trunc...
- Modified
- 24 Feb at 22:53
Cannot edit in read-only editor VS Code
I am using Visual Studio Code V 1.31.1. I used an input function but I can't write an input in output panel it shows this error > Cannot edit in read-only editor. Please help me solve this problem. ...
- Modified
- 24 Feb at 20:54
ServiceStack: Upgrade to 5.4.1 gives me ReflectionTypeLoadException on ServiceStack.Common
I was running ServiceStack 5.2.0, until I upgraded due [to this answer](https://stackoverflow.com/questions/54840831/servicestack-accessing-the-irequest-in-the-service-returns-null). After doing that,...
- Modified
- 13 Sep at 22:38
Disable code formatting for specific block of code in Visual Studio
How can I for a specific block of code in (C# 7)? I have this method: ``` public CarViewModel(ICarsRepo carsRepo) { ... Manufacturers = ToSelectList<Manufacturer>(); Categories = ToSele...
- Modified
- 1 Dec at 00:39
When do we need IOptions?
I am learning DI in .Net Core and I do not get the idea about the benefit of using `IOptions`. Why do we need `IOptions` if we can do without it? # With IOptions ``` interface IService { vo...
- Modified
- 23 Feb at 17:18
How do I set & fetch Environment variable in AWS Lambda Project in C#
I have created `AWS Lambda Project` in `C#` (NOT Serverless Application) [](https://i.stack.imgur.com/p3pJO.png) I have defined a Environment variable in `aws-lambda-tools-defaults.json` as below `...
- Modified
- 23 Feb at 18:22
ServiceStack: Accessing the IRequest in the Service returns null
I am using [Servicestack](https://servicestack.net/). I have a base class for my Services, like so: ``` public abstract class ServiceHandlerBase : Service ``` and then some methods and properties i...
- Modified
- 26 Feb at 21:45
Unable to resolve service for type 'Microsoft.AspNetCore.Mvc.IUrlHelper' while attempting to activate
I am trying to separate code from controller to service that I created. What I did is to create a User Service with interface IUserService. Moved RegisterUser code from directly controller to UserSer...
- Modified
- 23 Feb at 08:27
How to Add a new Name Value Pair to an Incoming Request's Headers in ServiceStack 5.0?
I have a custom Plugin I wrote which I add to the Plugins list inside the Configure method of AppHost. I'm using this plugin to authenticate the internal users that came through Postman. Get their cr...
- Modified
- 22 Feb at 21:35
Can Servicestack Deserialize XML without namespaces
I'm familiar with these two methods: ``` var newDataSet = XmlSerializer.DeserializeFromString<NEWDATASET>(xmlDoc.OuterXml); var newDataSet = xmlDoc.OuterXml.FromXml<NEWDATASET>(); ``` But they both...
- Modified
- 22 Feb at 20:35
Why Extra Copy in List<T>.AddRange(IEnumerable<T>)?
I'm looking at the open source code for [System.Collections.Generic.List<T>](https://referencesource.microsoft.com/#mscorlib/system/collections/generic/list.cs,245). The `AddRange(IEnumerable<T>)` me...
- Modified
- 20 Jun at 09:12
Dotnet publish not publishing DLL to publish directory
I want to publish my self contained .NET Core (2.2) application, however one specific NuGet package (`Microsoft.Management.Infrastructure`) is never published to the `publish` folder (as in the .dll f...
Working with Anaconda in Visual Studio Code
I am getting a bit confused here, the latest Anaconda Distribution, 2018.12 at time of writing comes with an option to install Microsoft Visual Studio Code, which is great. When launching VSC and aft...
- Modified
- 26 Feb at 01:41
typeof generic and casted type
Let's say we have generic method: ``` public void GenericMethod<T>(T item) { var typeOf = typeof(T); var getType = item.GetType(); } ``` And we are invoking it with the following parameters...
How to store all ctor parameters in fields
I'm learning C# and a thought came up when coding. Is it possible to automaticly store parameters from a constructor to the fields in a simple way without having to write `this.var = var` on every var...
ServiceStack: Multithreading using AppSelfHostBase - can it handle concurrent calls?
I read [this SO post](https://stackoverflow.com/questions/14238680/how-does-servicestack-handle-concurrent-calls), but it wasnt immediately clear to me how the AppSelfHostBase is handling the same que...
- Modified
- 22 Feb at 09:15
Connect to On Prem SQL server from Azure Web app
I have .Net application at on prim. I want to host it at Azure but don't want to move database. I publish the application on Azure but it is not able to connect to on prim database. SQL server is in...
- Modified
- 22 Feb at 09:18
FirstOrDefaultAsync() & SingleOrDefaultAsync() vs FindAsync() EFCore
We have 3 different approaches to get single items from EFCore they are `FirstOrDefaultAsync()`, `SingleOrDefaultAsync()` (including its versions with not default value returned, also we have `FindAs...
- Modified
- 4 Sep at 14:2
How to turn set Cache-Control using ServiceStack?
I want to turn off caching for my HTTP responses. Here's my code: `public class CacheControlHeaderAttribute : ResponseFilterAttribute { public override void Execute(IRequest req, IResponse res, obj...
- Modified
- 21 Feb at 21:10