c#-6.0

Enabling C# 6 in ASP.VNext projects in Visual Studio CTP2

时光总嘲笑我的痴心妄想 提交于 2020-01-23 06:46:25
问题 I have installed Visual Studio CTP2 and created a new ASP.Net Vext project. When I tried using C# 6.0 features, it was not working. I even tried the stpes in the following link. No C# 6.0 in Visual Studio 2015 CTP? But even after this I was not able to use C# 6 in VNext projects. Please help. 回答1: Add this to your project.json: "compilationOptions": { "languageVersion": "experimental" } 回答2: You should not add the net451 object. Use this inside the project.json file: { "compilationOptions": {

getting duplicate rows for each row using linq query

≯℡__Kan透↙ 提交于 2020-01-22 03:18:45
问题 I have db schema having tables like this below, i am trying to get the results using left join or normal join on these table using the below query. Somehow getting duplicate rows like as mentioned below. Requests (table) RequestStage (table) ------------- ---------------- id RequestStageid createdAt(datetime) name (values: RequestSubmitted,Inreview) RequestTypeId MasterSectionID RequestStatusID RequestStageID id (FK)(localCodes) MasterSections (table) ------------------------- MasterSectionId

Primary constructors no longer compile in VS2015

笑着哭i 提交于 2020-01-18 16:27:23
问题 Until this very day, I could make use of primary constructors, such as: public class Test(string text) { private string mText = text; } To be able to do this, in the previous Visual Studio CTP, I had to add this to the csproj-file: <LangVersion>Experimental</LangVersion> Anyhow, this no longer works in the Visual Studio 2015 Preview (with or without LangVersion ). Does anyone have any ideas about what could be going on? 回答1: Does anyone have any ideas about what could be going on? Yup -

Primary constructors no longer compile in VS2015

北慕城南 提交于 2020-01-18 16:27:08
问题 Until this very day, I could make use of primary constructors, such as: public class Test(string text) { private string mText = text; } To be able to do this, in the previous Visual Studio CTP, I had to add this to the csproj-file: <LangVersion>Experimental</LangVersion> Anyhow, this no longer works in the Visual Studio 2015 Preview (with or without LangVersion ). Does anyone have any ideas about what could be going on? 回答1: Does anyone have any ideas about what could be going on? Yup -

Primary constructors no longer compile in VS2015

坚强是说给别人听的谎言 提交于 2020-01-18 16:23:26
问题 Until this very day, I could make use of primary constructors, such as: public class Test(string text) { private string mText = text; } To be able to do this, in the previous Visual Studio CTP, I had to add this to the csproj-file: <LangVersion>Experimental</LangVersion> Anyhow, this no longer works in the Visual Studio 2015 Preview (with or without LangVersion ). Does anyone have any ideas about what could be going on? 回答1: Does anyone have any ideas about what could be going on? Yup -

Why GC does not collect an unused object

女生的网名这么多〃 提交于 2020-01-17 05:00:53
问题 I'm trying to understand how the GC acts when an object is not being used anymore, my test is to do nothing with the object (after used) but it didn't work, the object's destructor was never called. I've created an example program trying to wait until the object is destroyed, but after 4 hours running nothing happens. Note: I know if I set the object to null the GC will collect it, but I just want to see the "normal" way the GC itself collects the object. using System; using System

Does Dapper support c# 6 read-only properties in POCOs?

萝らか妹 提交于 2020-01-14 07:49:12
问题 Given the following: public class SomePoco { public int IntValue { get; } } and CREATE TABLE SomePocoStorage (IntValue INT NOT NULL) and INSERT SomePocoStorage VALUES (1), (274) If I call connection.Query<SomePoco>("SELECT * FROM SomePocoStorage") does Dapper handle populating the IntValue field on the returned SomePoco instances? 回答1: Good question! It isn't a scenario I've targeted, but I'd be more than happy to take a look at what would be involved. Since we already do a lot of nasty

How to create a static lambda for use with expression building?

你说的曾经没有我的故事 提交于 2020-01-13 10:20:47
问题 As of C# 6, lambdas now default to instance methods, and will never be static (which I assume means they always capture now, which I guess is more efficient [seems to be faster given the discussions]). See here: Why has a lambda with no capture changed from a static in C# 5 to an instance method in C# 6? and here: Difference in CSC and Roslyn compiler's static lambda expression evaluation? This causes issues now with using lambdas when creating static MethodInfos for calls to expression

New C# 6 object initializer syntax?

拜拜、爱过 提交于 2020-01-13 09:03:51
问题 I just noticed that the following is possible in C# written in Visual Studio 2015, but I've never seen it before: public class X { public int A { get; set; } public Y B { get; set; } } public class Y { public int C {get; set; } } public void Foo() { var x = new X { A = 1, B = { C = 3 } }; } My expectation was for Foo to have to be implemented like this: public void Foo() { var x = new X { A = 1, B = new Y { C = 3 } }; } Note that there is no need to call new Y . Is this new in C# 6? I haven't

New C# 6 object initializer syntax?

大兔子大兔子 提交于 2020-01-13 09:03:10
问题 I just noticed that the following is possible in C# written in Visual Studio 2015, but I've never seen it before: public class X { public int A { get; set; } public Y B { get; set; } } public class Y { public int C {get; set; } } public void Foo() { var x = new X { A = 1, B = { C = 3 } }; } My expectation was for Foo to have to be implemented like this: public void Foo() { var x = new X { A = 1, B = new Y { C = 3 } }; } Note that there is no need to call new Y . Is this new in C# 6? I haven't