question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Array injected in first As block becomes empty in second As block.

See original GitHub issue

Hi, Let say I have Vertex (People) on which I have ZipCode as one property, I have Edge (Know). Now I want to get all the People who I do not know and but comes under array of ZipCode.


  public class People :  IVertex
    {
        public string ZipCode { get; set; }
        public string Id { get; set; }
        public string Label { get; set; }
    }

var nearByZipCodes= new string[] {"10001","10199", "10121"};
var userId="";

 await _g.Inject(nearByZipCodes)
                  .Fold()
                   .As((_, injectedNearByZipCode) => _
                   .V<People>(userId).Both<Know>()
                     .OfType<People>()
                      .Values(c=>c.Id).Fold()
                       .As((__, knownPeople) => __
                         .V<People>().Where(c =>
                          !knownPeople.Value.Contains(c.Id) && injectedNearByZipCode.Value.Contains(c.ZipCode)))
                        );

I tried the above query but injectedNearByZipCode is empty in the second As block. is this expected behavior , if yes what will be proper way to write this query.

Thank you !

Version :

<PackageReference Include="ExRam.Gremlinq.Providers.CosmosDb" Version="8.0.0-preview-0294" />

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
danielcwebercommented, Aug 26, 2020

Beware of that caveat! Fold steps will erase your path history, including all the step labels. See here for more details on ReducingBarrierSteps. You have to keep that in mind, there’s no way Gremlinq can detect these (or is there?). A workaround is to wrap the right part of the query in a map operation:

var personWhoMarkDoesNotKnowAndBelongsToNearbyZipCode = await _g
    .Inject(nearByZipCodes)
    .Fold()
    .As((_, injectedNearByZipCode) => _
        .Map(__ => __
            .V<Person>(_marko.Id)
            .Both<Knows>()
            .OfType<Person>()
            .Fold())
        .As((__, knownPeople) => __
            .V<Person>()
            .Where(c => !knownPeople.Value.Contains(c) && injectedNearByZipCode.Value.Contains(c.ZipCode))));
0reactions
iAmBipinPaulcommented, Aug 26, 2020

Hi , @danielcweber Thank you, it works. I will go through the link you have provided.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Array.first Vs Array.shift in Ruby
When you called the method injecting on the array [1,2,3] , as acc was empty, sef.shift gets invoked. Now acc is 1 ....
Read more >
block.workspace.topBlocks is an empty array for all but the ...
This code assigns toolbox to the toolbox property after you've already called inject(..). What happens when you construct options immediately ...
Read more >
Inject Method: Explained
Here we are passing inject an initial value of an empty array. The first element between the || will always be the 'result'...
Read more >
module Enumerable - RDoc Documentation
With a block given, returns an array of two arrays: The first having those elements for which the block returns a truthy value....
Read more >
module Enumerable - Documentation for Ruby 2.1.0
Returns two arrays, the first containing the elements of enum for which the block evaluates to true, the second containing the rest. If...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found