Hey,
The problem number one:
I need to use a lot of dynamic and IDictionary<string, object> object instances (all JSON serializable) in the web app. However, when store them in Raven , raven creates 'crappy' json .
I don't know how to escape from Raven converting simple like HashSet<Guid> to "$type": "System.Collections.Generic.HashSet`1[[System.Guid, mscorlib]], "$values": ... It think this is small bug in the code. Its would be better to fix on raven level (private static bool ShouldSimplfyJsonBasedOnType(string typeValue, JsonProperty jsonProperty) then to have some patch in my code.
The question number two:
How to insert json to the Raven directly not trough session.Store but rather JSON string formatted accordingly raven db standard? I think I saw somewhere in samples or Raven Test app , but I can find right now. Can anybody give me a hint?
The question number three?
The remember watching Rob Aston's presentation on youtube and he mention passing complex query from IIS to the raven and getting results not deserialize to some C# object but passing JSON back to the browser user. Can anybody give me a hint?
var document = new Dictionary<string, object>(StringComparer.InvariantCultureIgnoreCase);
document["ProductHashSetId"] = new HashSet<Guid> { Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid() };
document["ProductListId"] = new List<Guid> { Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid() };
document["ProductArrayId"] = new List<Guid> { Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid() }.ToArray();
document["ProductCollectionId"] = new Collection<Guid> { Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid() };
session.Store(document, "mycollection/1");
session.SaveChanges();
OR
dynamic document = new ExpandoObject();
document.ProductHashSetId = new HashSet<Guid> { Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid() };
document.ProductListId = new List<Guid> { Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid() };
document.ProductArrayId = new List<Guid> { Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid() }.ToArray();
document.ProductCollectionId = new Collection<Guid> { Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid() };
session.Store(document, "mycollection/2");
session.SaveChanges();
{
"ProductHashSetId": {
"$type": "System.Collections.Generic.HashSet`1[[System.Guid, mscorlib]], System.Core",
"$values": [
"2d0e489a-2a81-49fd-b98c-0d468aebfaaf",
"6ce6bd6a-9602-4116-b6e6-6c88163b3369",
"6cba607c-0d5d-42fb-bdaa-3a75563d96ba"
]
},
"ProductListId": {
"$type": "System.Collections.Generic.List`1[[System.Guid, mscorlib]], mscorlib",
"$values": [
"12d876ff-3d98-478b-9351-6e130245ed07",
"963594de-16fe-4c78-95d6-1a13cfa9f655",
"ce0a681d-f290-4cbc-b7fa-e6ca630f8540"
]
},
"ProductArrayId": {
"$type": "System.Guid[], mscorlib",
"$values": [
"b3d0c0ca-6bf2-42a8-9b1d-4b9f79d6f40e",
"6936bdce-7302-431b-9cf5-1f9828db4f61",
"2d265054-6d81-4843-b3c9-20487908af7d"
]
},
"ProductCollectionId": {
"$type": "System.Collections.ObjectModel.Collection`1[[System.Guid, mscorlib]], mscorlib",
"$values": [
"2092b56a-7e8a-484e-b132-590e741b2a94",
"95982c2c-7e33-45d2-916e-2d63ff8315a6",
"943376d7-63b7-4745-9b0a-bf5262729ea5"
]
}
}
Should be something like that:
{
"ProductHashSetId": [
"2d0e489a-2a81-49fd-b98c-0d468aebfaaf",
"6ce6bd6a-9602-4116-b6e6-6c88163b3369",
"6cba607c-0d5d-42fb-bdaa-3a75563d96ba"
],
"ProductListId": [
"12d876ff-3d98-478b-9351-6e130245ed07",
"963594de-16fe-4c78-95d6-1a13cfa9f655",
"ce0a681d-f290-4cbc-b7fa-e6ca630f8540"
],
"ProductArrayId": [
"b3d0c0ca-6bf2-42a8-9b1d-4b9f79d6f40e",
"6936bdce-7302-431b-9cf5-1f9828db4f61",
"2d265054-6d81-4843-b3c9-20487908af7d"
],
"ProductCollectionId": [
"2092b56a-7e8a-484e-b132-590e741b2a94",
"95982c2c-7e33-45d2-916e-2d63ff8315a6",
"943376d7-63b7-4745-9b0a-bf5262729ea5"
]
}