Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Any way to query data from multiple nodes and return it all as one row? #5

Closed
hewhofreeks opened this issue Jun 24, 2020 · 5 comments
Closed

Comments

@hewhofreeks
Copy link

For example, in our data structure we have Areas related to our business model which contain many ZipCodes and then each ZIpCode is associated with a City which is associated with a State. I would like to be able to take in a single Area Uid and then return a list of ZipCodes, the City Name it's in, and the state abbreviation.

What I'm looking for it to do something like this:

                var zipQuery = Transaction.CompiledQuery.Match(Node.ZipCode.Alias(out var zipCode)
                    .In.ZIPCODE_LOCATED_IN_CITY.Out.City.Alias(out var city).In.CITY_LOCATED_IN_STATE.Out.State.Alias(out var state))
                    .Match(Node.ContractorServiceArea.Alias(out var serviceArea).Out.INCLUDES_ZIP.In.ZipCode.Alias(out zipCode))
                    .Where(serviceArea.Uid == Parameter.New<string>("serviceAreaUid"))
                    .Return(zipCode.Zip, state.Abbr, city.Name)
                    .Compile();

Which generates the exact cypher I'd like to be able to run, but cannot figure out a way to run this query which might return the correct anonymous data types. I only see the
.LoadWhere()

queries on the created OGM objects.

I also honestly cannot tell the benfits of putting in multiple values in the .Return method either. It always seems like the return values are going to be attempted to be parsed into whatever static method you're running the .LoadWhere from.

Am I missing something or is this just a limitation of blueprint41?

@circles-arrows
Copy link
Owner

circles-arrows commented Jun 25, 2020

You can do something like this:

QueryExecutionContext context = zipQuery.GetExecutionContext();
context.SetParameter("serviceAreaUid", <Your Uid Here>);
List<dynamic> resultSet = context.Execute();

@hewhofreeks
Copy link
Author

Awesome, thanks. Had no idea you could do this.

@ngallegos
Copy link

@circles-arrows , using the resultSet above, how would one go about getting the same objects that are returned from the LoadWhere() method. For example, if we had .Return(zipCode, state, city) instead of .Return(zipCode.Zip, state.Abbr, city.Name), how would I go about extracting the actual ZipCode, State, and City objects that would have come from ZipCode.LoadWhere(), State.LoadWhere() and City.LoadWhere() respectively?

@circles-arrows
Copy link
Owner

circles-arrows commented Sep 1, 2020 via email

@ngallegos
Copy link

Sounds good. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants