Comments (4)
Hi devcrp,
Thanks for the repo code. I was able to reproduce the issue. I was using a .net core application and you were using .net framework. It works fine in .net core, but is broken in .net framework. The issue will be fixed in the next release which will hopefully happen soon., For now you can do the following workaround.
public static async Task<string> Insert(Person person)
{
using (var cosmosClient = new CosmosClient(new CosmosConfiguration(ENDPOINT, KEY).UseCustomJsonSerializer(new CustomJsonSerializer())))
{
var container = cosmosClient.Databases[DB].Containers[CONTAINER];
var response = await container.Items.CreateItemAsync(person.id, person);
return JsonConvert.SerializeObject(person);
}
}
public static async Task<Person> Get(string id)
{
using (var cosmosClient = new CosmosClient(new CosmosConfiguration(ENDPOINT, KEY).UseCustomJsonSerializer(new CustomJsonSerializer())))
{
var container = cosmosClient.Databases[DB].Containers[CONTAINER];
CosmosItemResponse<Person> result = await container.Items.ReadItemAsync<Person>(id, id: id);
return result.Resource;
}
}
/// <summary>
/// The default Cosmos JSON serializer
/// </summary>
internal class CustomJsonSerializer : CosmosJsonSerializer
{
private static readonly JsonSerializer Serializer = new JsonSerializer();
private static readonly Encoding DefaultEncoding = new UTF8Encoding(false, true);
public override T FromStream<T>(Stream stream)
{
using (stream)
{
if (typeof(Stream).IsAssignableFrom(typeof(T)))
{
return (T)(object)(stream);
}
using (StreamReader sr = new StreamReader(stream))
{
using (JsonTextReader jsonTextReader = new JsonTextReader(sr))
{
return CustomJsonSerializer.Serializer.Deserialize<T>(jsonTextReader);
}
}
}
}
public override Stream ToStream<T>(T input)
{
MemoryStream streamPayload = new MemoryStream();
using (StreamWriter streamWriter = new StreamWriter(streamPayload, encoding: CustomJsonSerializer.DefaultEncoding, bufferSize: 1024, leaveOpen: true))
{
using (JsonWriter writer = new JsonTextWriter(streamWriter))
{
writer.Formatting = Newtonsoft.Json.Formatting.None;
CustomJsonSerializer.Serializer.Serialize(writer, input);
writer.Flush();
streamWriter.Flush();
}
}
streamPayload.Position = 0;
return streamPayload;
}
}
from azure-cosmos-dotnet-v3.
Hi devcrp,
I was not able to repo the issue. I created the item via the SDK and viewed it in the portal data explorer and it appears fine.
dynamic test = new { id = "newid", name = "Román", AccountNumber = "1234890" };
var response = await container.Items.CreateItemAsync(test.AccountNumber, test);
What are you using to view the inserted item? When you read the item back via the SDK is it still correct? Can you provide a link to a github repository with the repo?
from azure-cosmos-dotnet-v3.
Hi j82w,
Here's the test project where I can reproduce the issue: https://github.com/devcrp/CosmosDBvsDiacritics
In this case I'm using the cosmosDB emulator to test it locally, but the result is the same when using the CosmosDB in the Azure server.
Also, here's where I'm viewing the inserted item
And this is the container's config in case it helps
from azure-cosmos-dotnet-v3.
That did it, thank you!!
from azure-cosmos-dotnet-v3.
Related Issues (20)
- Updating Cosmo db from 3.29 to 3.31.2+ causes Kestrel issues HOT 9
- Hedging With Writes on MultiMaster
- [FEATURE REQ] Resolve Native AOT Warnings in Microsoft.Azure.Cosmos
- Distributed Tracing: Pass more information in an event along with request diagnostics
- Documentation: CosmosClientOptions.OpenTcpConnectionTimeout recommends > 5 seconds
- Group by with continuation token
- LoadBalancingPartition: Clean-Up Unhealthy Dangling Connections.
- Incorrect order of items on "Order by" query on multi-partition container HOT 1
- ChangeFeed: Investigating Compute Gateway AVAD Archival Tree Bounded Caching
- Update `Azure.Core` Library to Latest Nuget Release
- Money maker HOT 2
- ChangeFeedProcessor: AVAD Response to Include More Intrinsic Information (specifically Feed Range) and API to validate processed LSNs
- Microsoft.Azure.Cosmos copies older vcruntime140 DLLs, creating risk of ABI breaks + crashes HOT 2
- LINQ custom serializer: query translated incorrectly when passing variable to the nested "where" clause HOT 4
- COUNT is including expired TTL documents that are pending deletion HOT 3
- Make the `VectorIndexes` setter as `internal` in `IndexingPolicy`
- TcpOpenConnectionTimeout TimeSpan contract not honoring values less than a second
- What is the stream needed for or how is it used in `PatchItemStreamAsync`? HOT 2
- Microsoft.Azure.Cosmos.Encryption.Custom 1.0.0-preview06 is incompatible with Cosmos 3.40.0-preview.0 and newer
- Change Feed / Processor: AVAD timeToLiveExpired deserialization Issue
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from azure-cosmos-dotnet-v3.