Iteration inside OperationResult

Hello my name is Mario Herrero, this is my first post ever in SCRIBE forums, iam currently developing a connector using the CDK and i found myself against a wall. How do i retrieve multiple rows on a OperationResult?, for example: how can i output multiple DataEntity Objects in the same OperationResult so i can iterate among them?

Here is an example of my code:

 

//My JSON Object

      var jo = JObject.Parse(list);

      //the Total of iterations i will need to process

      int watchCount = Convert.ToInt32(jo["total"].ToString());

      //init my DataEntity array

      DataEntity[] comentarios = new DataEntity[watchCount];

      //Everybody knows what a for is :)

      for (int i = 0; i < watchCount; i++)

      {

        //this two variables i will need to store to scribe

        string author = jo["comments"][i]["author"]["name"].ToString();

        string body = jo["comments"][i]["body"].ToString();

        //fill my DataEntity array

        comentarios[i] = new DataEntity(Comments.GetCommentEntityName)

        {

          Children = new EntityChildren(),

          Properties = new EntityProperties { { Comments.GetCommentBodyPropertyName, body },

                              { Comments.GetCommentAuthorPropertyName, author } }

        };

      }

      //then return it to scribe

      return new OperationResult

      {

        ObjectsAffected = new[] { 1 },

        Output = comentarios,

        Success = new[] { true }

      };

 

In this code if the array only stores one DataEntity, then its fine i can see it in Scribe online, but if it stores multiple objects then it gives me an error, i know there must be a way to iterate among multiple results in a Create Operation.

Thanks in advance.

(5) Answers

Login