.net-core-3.1

Operation is not valid due to the current state of the object (System.Text.Json)

只谈情不闲聊 提交于 2020-04-07 05:05:58
问题 We've got an API, which simply posts incoming JSON documents to a message bus, having assigned a GUID to each. We're upgrading from .Net Core 2.2 to 3.1 and were aiming to replace NewtonSoft with the new System.Text.Json library. We deserialise the incoming document, assign the GUID to one of the fields and then reserialise before sending to the message bus. Unfortunately, the reserialisation is failing with the exception Operation is not valid due to the current state of the object . Here's

Operation is not valid due to the current state of the object (System.Text.Json)

本秂侑毒 提交于 2020-04-07 05:05:47
问题 We've got an API, which simply posts incoming JSON documents to a message bus, having assigned a GUID to each. We're upgrading from .Net Core 2.2 to 3.1 and were aiming to replace NewtonSoft with the new System.Text.Json library. We deserialise the incoming document, assign the GUID to one of the fields and then reserialise before sending to the message bus. Unfortunately, the reserialisation is failing with the exception Operation is not valid due to the current state of the object . Here's

.net core 3 yields different floating point results from version 2.2

旧街凉风 提交于 2020-03-16 07:28:46
问题 Here is a sample piece of code with outputs from .net core 2.2 and 3.1. It shows different computational results for a basic floating point expression a^b. In this example we calculate 1.9 to the power of 3. Previous .NET frameworks yielded the correct result, but .net core 3.0 and 3.1 yields a different result. Is this an intended change and how can we migrate financial calculation code to the new version with a guarantee that numerical calculations will still yield the same results? (It

.NET Core 3.1 ChangePasswordAsync Inner Exception “Cannot update Identity column”

一笑奈何 提交于 2020-03-14 11:08:31
问题 I am upgrading a .NET Core Web API from 2.2 to 3.1. When testing the ChangePasswordAsync function, I receive the following error message: Cannot update identity column 'UserId'. I ran a SQL Profile and I can see that the Identity column is not included in the 2.2 UPDATE statement but it is in 3.1. The line of code in question returns NULL, as opposed to success or errors, and is as follows: objResult = await this.UserManager.ChangePasswordAsync(objUser, objChangePassword.OldPassword,

.NET Core 3.1 ChangePasswordAsync Inner Exception “Cannot update Identity column”

久未见 提交于 2020-03-14 11:08:28
问题 I am upgrading a .NET Core Web API from 2.2 to 3.1. When testing the ChangePasswordAsync function, I receive the following error message: Cannot update identity column 'UserId'. I ran a SQL Profile and I can see that the Identity column is not included in the 2.2 UPDATE statement but it is in 3.1. The line of code in question returns NULL, as opposed to success or errors, and is as follows: objResult = await this.UserManager.ChangePasswordAsync(objUser, objChangePassword.OldPassword,

Derived type's properties missing in JSON response from ASP.NET Core API

痞子三分冷 提交于 2020-02-24 20:58:06
问题 The JSON response from my ASP.NET Core 3.1 API controller is missing properties. This happens when a property uses a derived type; any properties defined in the derived type but not in the base/interface will not be serialized to JSON. It seems there is some lack of support for polymorphism in the response, as if serialization is based on a property's defined type instead of its runtime type. How can I change this behavior to ensure that all public properties are included in the JSON response

Problem with EF OrderBy after migration to .net core 3.1

一个人想着一个人 提交于 2020-02-02 05:20:55
问题 Consider this code: _dbContext.Messages .GroupBy(m => new { MinId = m.SenderId <= m.RecipientId ? m.SenderId : m.RecipientId, MaxId = m.SenderId > m.RecipientId ? m.SenderId : m.RecipientId }) .Select(gm => gm.OrderByDescending(m => m.SentAt).FirstOrDefault()); By this I group all dialogues of users by their Id's no matter who sent the message. Then I order messages by SentAt date inside the groups and select one last message out of each dialogue. The thing is that this code worked and more

Problem with EF OrderBy after migration to .net core 3.1

生来就可爱ヽ(ⅴ<●) 提交于 2020-02-02 05:20:28
问题 Consider this code: _dbContext.Messages .GroupBy(m => new { MinId = m.SenderId <= m.RecipientId ? m.SenderId : m.RecipientId, MaxId = m.SenderId > m.RecipientId ? m.SenderId : m.RecipientId }) .Select(gm => gm.OrderByDescending(m => m.SentAt).FirstOrDefault()); By this I group all dialogues of users by their Id's no matter who sent the message. Then I order messages by SentAt date inside the groups and select one last message out of each dialogue. The thing is that this code worked and more

Execute stored procedure in EF Core 3.0 vs 2.2

本小妞迷上赌 提交于 2020-01-24 03:56:29
问题 I am trying to update my code to accommodate changes in EF Core 3.0, specifically the deprecation of ExecuteSqlCommand . The following code was working in 2.2 but as stated, I need to get rid of ExecuteSqlCommand : SqlParameter srcid = new SqlParameter("@srcCharacterId", participantApplication.CharacterId); SqlParameter newid = new SqlParameter("@newCharacterId", newCharacterId); SqlParameter pResult = new SqlParameter { ParameterName = "@pResult", SqlDbType = System.Data.SqlDbType.Bit,

Deserialize anonymous type with System.Text.Json

泄露秘密 提交于 2020-01-14 13:55:11
问题 I am updating some apps for .NET Core 3.x, and as part of that I'm trying to move from Json.NET to the new System.Text.Json classes. With Json.NET, I could deserialize an anonymous type like so: var token = JsonConvert.DeserializeAnonymousType(jsonStr, new { token = "" }).token; Is there an equivalent method in the new namespace? 回答1: As pointed out by dbc above, this just isn't possible currently. We looked at JsonDocument as a workaround, but it's also missing things like case insensitivity