Hi Steve,
A couple of things to consider. You mention working with an 'entity
selection' but then get into talking about collections. To create a
collection from an entity selection, or only some properties of it, take a
look at .toCollection().
https://doc.4d.com/4Dv18R3/4D/18-R3/entitySelectiontoCollection.305-4900500.en.html

This might give you want you want right there as you pass a comma delimited
string to the method.

The other approach is to simply do a query for what you need. These are
really fast in ORDA thanks to a lot of optimization built in and it's very
flexible.
https://doc.4d.com/4Dv18R3/4D/18-R3/dataClassquery.305-4900853.en.html

The old way of approaching these sorts of situations where you paid a big
performance hit for multiple searches isn't nearly so true now. But it
depends on your data. Try it and see.

On Mon, May 11, 2020 at 9:04 PM Steve Slanec via 4D_Tech <
[email protected]> wrote:

> I'm trying come up with generic code that produces a projection from an
> entity selection, and I think must be missing something obvious.  I’d like
> to perform the following statement:
>
> $collection:=$employees.company.country
>
> But as generic code. I want to be able to pass the ORDA path
> “company.country” as a text variable so that I can change it at runtime.
>
> Obviously, using square bracket notation doesn’t work because square
> brackets for entity selections are used for indexes:
>
> $collection:=$employees[“company.country”]  // Syntax error
>
> So how can I do this?
>
> I guess I could write a method that splits the ORDA path into tokens,
> examines each token individually, and traverses through relations if the
> token kind is a “relation" until we get to the last token, whose kind must
> be “storage".  But I’m hoping I’m just being ignorant - it seems like a lot
> of work for doing what object notation does so simply and elegantly.
>
> Using 4D v18, macOS 10.14
>
> Thanks for any advice!
>
> - Steve
>
>
>
> Steve Slanec
> Slanecon Digital
>
> **********************************************************************
> 4D Internet Users Group (4D iNUG)
> New Forum: https://discuss.4D.com
> Archive:  http://lists.4d.com/archives.html
> Options: https://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:[email protected]
> **********************************************************************



-- 
Kirk Brooks
San Francisco, CA
======================
**********************************************************************
4D Internet Users Group (4D iNUG)
New Forum: https://discuss.4D.com
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[email protected]
**********************************************************************

Reply via email to