Questions

Enumerable.Empty<T>().AsQueryable(); This method supports the LINQ to Entities infrastructure and is not intended to be used directly from your code

I am getting runtime error > This method supports the LINQ to Entities infrastructure and is not intended to be used directly from your code.Description: An unhandled exception occurred during the...

How to manage the version number in Git?

Let's imagine the [blerp](http://xkcd.com/1692/) command line tool maintained on [git](/questions/tagged/git). This tool has the (hidden) `--version` option which returns its [version](https://en.wiki...

2 Sep at 17:19

ASP.NET Core DependencyResolver

In ASP.NET MVC 5 is possible to obtain some dependency through `DependencyResolver.Current.GetService<T>()`. Is there something similar in ASP.NET Core?

Git - remote: Repository not found

I have SourceTree with local working copy. And all operations work good, I can simple fetch, push, pull and etc via SourceTree. I just needed to make force push which does not exist in SourceTree. I ...

14 Jun at 13:31

Swashbuckle adding 200 OK response automatically to generated Swagger file

I am building swagger docs using Swashbuckle in my WebApi 2 project. I have the following definition of the method: ``` [HttpPost] [ResponseType(typeof(Reservation))] [Route("reservations")] [Swagge...

14 Jun at 18:37

ServiceStack 4.0.60: How to modify/kill sessions if the default behaviour is to not persist them to cache?

In my existing application I am able to log out (destroy) sessions because I keep a list of session Id's associated to a user. This would allow me to provide functionality like "log out all other sess...

Check if a type belongs to a namespace without hardcoded strings

Is it possible to check if a type is part of a namespace without using harcoded strings? I'm trying to do something like: ``` Type type = typeof(System.Data.Constraint); if(type.Namespace == System....

14 Jun at 12:31

async TryParse(...) pattern

There are a lot of common `bool TryXXX(out T result)` methods in the .NET BCL, the most popular being, probably, `int.TryParse(...)`. I would like to implement an `TryXXX()` method. Obviously, I can...

15 Jun at 13:21

ServiceStack Serialize and Deserialize Dictionary with Objects

I have a very weird problem here pertaining to ServiceStack.Text's serializer. Suppose I have two classes, one called `Person` and another called `Address`. Person: ``` public class Person { p...

14 Jun at 10:31

What is a complex type in entity framework and when to use it?

I have tried to read the msdn [article](https://msdn.microsoft.com/en-us/library/cc716799(v=vs.100).aspx) on complex types. But it does not explain when to use it. Also there is not a comprehensive ex...

14 Jun at 07:56

Cookies in ASP.Net MVC 5

I am developing an application in which users are SignUp or SignIn by External Identity Providers like AAD, Google, WS-Federated Authentication etc. Now I want to create cookies on a user machine to l...

2 Mar at 12:42

How do I resolve C# dependencies automatically?

I've been reading about Unity's dependency injection and I understand it's a thing and that it allows you to type a class to an interface. What I'm curious about is, do I HAVE to? In the below scena...

21 Jun at 14:52

Ruby: What does the comment "frozen_string_literal: true" do?

This is the `rspec` binstub in my project directory. ``` #!/usr/bin/env ruby begin load File.expand_path("../spring", __FILE__) rescue LoadError end # frozen_string_literal: true # # This file was ...

7 Mar at 23:2

Content Security Policy directive: "frame-ancestors 'self'

I am embedding an iFrame in my web page, something like this: ``` var iframeProps = { 'data-type': self.props.type, allowTransparency: self.props.allowTransparency, className:...

13 Jun at 23:56

Display project version in ASP.NET MVC Core application (RC2)

How do I display application version from the project.json? I am using `gulp-bump` to autoincrement version, but I can't show the recent version. Here is what I'm trying: ``` @(Microsoft.Extensions.P...

How to hydrate a Dictionary with the results of async calls?

Suppose I have code that looks like this: ``` public async Task<string> DoSomethingReturnString(int n) { ... } int[] numbers = new int[] { 1, 2 , 3}; ``` Suppose that I want to create a dictionary ...

13 Jun at 17:49

Serialize enum values as camel cased strings using StringEnumConverter

I'm trying to serialize a list of objects to JSON using Newtonsoft's JsonConvert. My Marker class includes an enum, and I'm trying to serialize it into a camelCase string. Based on other Stackoverfl...

14 Sep at 09:53

Integer division in Java

This feels like a stupid question, but I can't find the answer anywhere in the Java documentation. If I declare two ints and then divide them, what exactly is happening? Are they converted to `floats/...

23 Mar at 09:18

How to return HTTP 500 from ASP.NET Core RC2 Web Api?

Back in RC1, I would do this: ``` [HttpPost] public IActionResult Post([FromBody]string something) { try{ // ... } catch(Exception e) { return new HttpStatusCodeRe...

14 Nov at 01:14

IE and Edge fix for object-fit: cover;

I'm using `object-fit: cover;` in my CSS for images on a specific page, because they need to stick on the same `height`. It works great in most browsers. But when scaling my browser in IE or Edge, t...

13 Jun at 14:55

WPF + MVVM + RadioButton : How to handle binding with single property?

From [this](https://stackoverflow.com/questions/2284752/mvvm-binding-radio-buttons-to-a-view-model) and [this](https://stackoverflow.com/questions/883246/mvvm-radiobuttons) (and other) questions on St...

2 Feb at 09:43

How to copy folders to docker image from Dockerfile?

I tried the following command in my Dockerfile: `COPY * /` and got mighty surprised at the result. Seems the naive docker code traverses the directories from the glob and then dumps the each file in t...

13 Jun at 13:37

Type or namespace name 'Data' does not exist in the namespace 'System'

I'm trying to build my first ASP.NET Web Forms project but I'm facing some serious problem. I created two project files in my project named: BLL and DAL. I created classes named `class.cs` and `class1...

30 Aug at 07:17

MongoDB C# Get all documents from a list of IDs

I have a list of Ids ``` List<string> Ids; ``` and I would like to retrieve all the documents matching these Ids. There are solutions on the web: ``` var ids = new int[] {1, 2, 3, 4, 5}; var quer...

13 Jun at 11:55

"Object doesn't support property or method 'find'" in IE

``` <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></scr...