How come properties with only a getter are serialized to RavenDB?

330 views
Skip to first unread message

Dos

unread,
Jun 2, 2012, 6:57:21 PM6/2/12
to ravendb
I have a couple of properties that are calculated based on the values
of other properties. These are getter-only properties. How come
they're being persisted to Raven? I can see the values of these
properties in Raven Studio. This seems strange, since there's no way
Raven could deserialize those values back in to the object?

Kijana Woodard

unread,
Jun 2, 2012, 7:15:05 PM6/2/12
to rav...@googlegroups.com
You'd think so, until you saw this:

Check out  HashedPassword and passwordSalt.

I tried this...and it just works.

Dos

unread,
Jun 2, 2012, 7:22:33 PM6/2/12
to ravendb
Well, there's a private set on HashedPassword. The property I'm
talking about literally had no setter, and is calculated from other
values on the object, so even if Raven could somehow magically set the
computed getter-only property, I wouldn't want it to. So what gives??

On Jun 2, 6:15 pm, Kijana Woodard <kijana.wood...@gmail.com> wrote:
> You'd think so, until you saw this:https://github.com/ayende/RaccoonBlog/blob/master/RaccoonBlog.Web/Mod...

Itamar Syn-Hershko

unread,
Jun 2, 2012, 9:17:15 PM6/2/12
to rav...@googlegroups.com
They will be persisted, but will not deserialize. If you don't want it serialized put a JsonIgnore attribute on it.

Oren Eini (Ayende Rahien)

unread,
Jun 3, 2012, 3:18:26 AM6/3/12
to rav...@googlegroups.com
Dos,
It is a useful way to expose calculated properties for indexing / projection.

Dos

unread,
Jun 3, 2012, 3:59:55 PM6/3/12
to rav...@googlegroups.com
That makes perfect sense!  Thanks very much to all of you for your replies.  I'll use the [JsonIgnore] attribute for now on those properties I don't want serialized, and keep that in my back pocket for any projections/indexing.

Thanks!


On Sunday, June 3, 2012 2:18:26 AM UTC-5, Oren Eini wrote:
Dos,
It is a useful way to expose calculated properties for indexing / projection.

Reply all
Reply to author
Forward
0 new messages