Raven4 - Needs a LoadAsync(id, type)

51 views
Skip to first unread message

Marcelo Volmaro

unread,
Sep 21, 2017, 9:37:31 AM9/21/17
to RavenDB - 2nd generation document database
I just have the need to load an entity that I don't know their type at compile time, and I don't want to mess with reflection to call the LoadAsync<> method. 
It would be great if we could have another LoadAsync that takes the type of the entity from the params and not from the generics arguments.

kar...@ayende.com

unread,
Sep 21, 2017, 1:03:50 PM9/21/17
to RavenDB - 2nd generation document database
Hi, 
try using LoadAsync<dynamic>(id);

Oren Eini (Ayende Rahien)

unread,
Sep 22, 2017, 4:16:01 AM9/22/17
to ravendb
Note that LoadAsync<object>(id) (or dynamic) will use the Raven-Clr-Type from the metaddata.

Hibernating Rhinos Ltd  

Oren Eini l CEO Mobile: + 972-52-548-6969

Office: +972-4-622-7811 l Fax: +972-153-4-622-7811

 


--
You received this message because you are subscribed to the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Felipe Leusin

unread,
Sep 22, 2017, 8:32:20 AM9/22/17
to RavenDB - 2nd generation document database
I know I'm a little late but I once used Load<RavenJObject>(id) then deserialized the RavenJObject to my class, I think this might help. (Dunno about 4.0)
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+u...@googlegroups.com.

Oren Eini (Ayende Rahien)

unread,
Sep 22, 2017, 8:33:43 AM9/22/17
to ravendb
Won't work in 4.0, we delete RavenJ* 
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+unsubscribe@googlegroups.com.

Marcelo Volmaro

unread,
Sep 22, 2017, 9:22:05 AM9/22/17
to RavenDB - 2nd generation document database
That will work. I already know the type that I need in advance and it must match what is stored (if it doesn't, it's a bug). But I know it at runtime, not at compile time. LoadAsync<object> would work for me.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+u...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages