Query with Load and string interpolation

29 views
Skip to first unread message

Jens Pettersson

unread,
Dec 12, 2017, 10:16:03 AM12/12/17
to RavenDB - 2nd generation document database
Hello.

Is there any plans to support queries with Load(...) and string interpolation?

We just got bitten by this when trying to use a query like this:

var query = from u in session.Query<User>()
where u.LastName == "Garcia"
let detail = session.Load<Detail>($"details/{u.DetailShortId}")
select new
{
Name = u.Name,
Detail = detail
};

In this query, detail is null.

This works: 

let detail = session.Load<Detail>("details/" + u.DetailShortId)

as it generates a query where the load looks like this:

var detail = load((""details/""+u.DetailShortId));

the first example generates a query like this, and that's why it doesn't work:

var detail = load(System.String.Format("details/{0}",u.DetailShortId)

The problem is that the query isn't failing in any way, it just doesn't return anything in the load as the id string isn't quite what you might expect. If string interpolation shouldn't/can't be supported, maybe some kind of runtime exception when trying to use it in a query?

I've got a failing test for the string interpolation version here:


I guess it's the JavascriptConversionExtensions.LoadSupport that is responsible for this, but I didn't manage to find a great place to add support for this...

//J

Oren Eini (Ayende Rahien)

unread,
Dec 12, 2017, 4:37:03 PM12/12/17
to ravendb
Thanks, I created an issue for that:

It won't be in the RTM, but we'll try to get it shortly after

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.

Reply all
Reply to author
Forward
0 new messages