Created
January 17, 2012 21:54
-
-
Save danielwertheim/1629176 to your computer and use it in GitHub Desktop.
Ano types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var r = session.Query<Photo>().ToEnumerableOfJson() | |
.Select(s => s.Deserialize(new { Votes = 0, User = "" })) //The call | |
.GroupBy(s => s.User).ToArray(); | |
//Ok, so the problem is that Votes and User doesn't get setters, right? But the have fields. | |
//E.g "<Votes>i__Field" which could be used | |
//Or perhaps the contract could be used to create a typed dictionary. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static T Deserialize<T>(this string json, T contract) | |
{ | |
return (T)JsonSerializer.DeserializeFromString(json, typeof(T)); | |
} |
Sure it is, but that's not something that need to be in SST. You should
only look at if a Type is anonymous then instead of expect setters access
the fields.
The syntax is not worse than MongoDb's map part in javascript. You need to
create the template.
//Daniel
…On 17 January 2012 22:57, Demis Bellot < ***@***.*** > wrote:
hmmm, Don't you think that it's a bit unreadable? you're passing in an
anonType + values for the structure of your type that you want to get out?
---
Reply to this email directly or view it on GitHub:
https://gist.github.com/1629176
Note: this can be done outside of the serializer - just send it a type that has getters + setters.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hmmm, Don't you think that it's a bit unreadable? you're passing in an anonType + values for the structure of your type that you want to get out?