Why there is no simpler way to do Basic Projection when querying by ID?

60 views
Skip to first unread message

Plamen Boudinov

unread,
Apr 6, 2017, 3:33:06 AM4/6/17
to RavenDB - 2nd generation document database
Basic projection is something you can do while Querying:

var results = session .Query<Employee, Employees_ByFirstAndLastName>()
.Where(x => x.ID == SomeId) .Select(x => new { FirstName = x.FirstName, LastName = x.LastName }) .ToList();


Is this the only way to fetch couple of fields, without explicitly creating a transformer - by querying an index which has ID field included explicitly?

Thanks

Oren Eini (Ayende Rahien)

unread,
Apr 6, 2017, 3:55:17 AM4/6/17
to ravendb
You want to do that by id, as part of the load?

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.

Plamen Boudinov

unread,
Apr 6, 2017, 12:51:22 PM4/6/17
to RavenDB - 2nd generation document database
Yea, but i see it does not make sense to be using the Load method, maybe some method, like QueryById that returns RavenQueriable?
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+u...@googlegroups.com.

Kijana Woodard

unread,
Apr 6, 2017, 3:02:02 PM4/6/17
to rav...@googlegroups.com
Sounds like you're looking for Load with a Transformer, but instead using the Select linq syntax. 
Are you doing this to reduce the number of bytes going across the network?

ref:



To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+unsubscribe@googlegroups.com.

Plamen Boudinov

unread,
Apr 11, 2017, 10:54:30 AM4/11/17
to RavenDB - 2nd generation document database
Yea, that is the reason. And having to declare an explicit transformers for all scenarios is a bit cumbersome, where you have the convenience Select projection with Query.

Oren Eini (Ayende Rahien)

unread,
Apr 12, 2017, 3:43:46 AM4/12/17
to ravendb
You can use a transformer that takes parameters, then just use that.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+unsubscribe@googlegroups.com.

Kijana Woodard

unread,
Apr 12, 2017, 8:28:15 AM4/12/17
to rav...@googlegroups.com
 @Oren, what do you mean? A generic transformer that takes a select list as a parameter?

Oren Eini (Ayende Rahien)

unread,
Apr 14, 2017, 5:32:23 AM4/14/17
to ravendb
Reply all
Reply to author
Forward
0 new messages