Skip to content

Instantly share code, notes, and snippets.

@danielwertheim
Created January 17, 2012 21:54
Show Gist options
  • Save danielwertheim/1629176 to your computer and use it in GitHub Desktop.
Save danielwertheim/1629176 to your computer and use it in GitHub Desktop.
Ano types
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.
public static T Deserialize<T>(this string json, T contract)
{
return (T)JsonSerializer.DeserializeFromString(json, typeof(T));
}
@mythz
Copy link

mythz commented Jan 17, 2012

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?

@danielwertheim
Copy link
Author

danielwertheim commented Jan 17, 2012 via email

@mythz
Copy link

mythz commented Jan 17, 2012

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