0

I am using eos-sharp to get table rows in ASP.NET. By default in the table, I want to show the latest 10 records of the table. So I get them using:

GetTableRowsResponse tabledata = await eos.GetTableRows(new GetTableRowsRequest()
{
  json = true,
  code = contract,
  scope = contract,
  table = tables[0],
  reverse = true,
  lower_bound="0",
  upper_bound="-9",
  limit = 10
});

Now I need the next and previous 10 records. I tried for the next 10 records:

lower_bound="10",
upper_bound="-19",

But not getting records as expected. What values for lower bound and upper bound should be set? Please help

1 Answer 1

1

lower_bound and upper_bound set the range of primary key of items you want to retrieve. If you want to get first 10 items, then call get_table_rows by lower_bound and upper_bound with the value "", and it will return "next_key" in the result. Then pass the value of "next_key" to lower_bound (or if you want to call with "reverse": true, then next_key needs to be passed to upper_bound). You don't need to set both of lower_bound and upper_bound, because the number of items is deteremined by "limit": 10.

Updated(04/17/2021)

EosSharp is outdated. You need to add EosSharp to your project (instead of installing by NuGet), and modify it.

https://github.com/GetScatter/eos-sharp/blob/32bca887/EosSharp/EosSharp.Core/Api/v1/Definitions/EosApiMethodDef.t4#L252-L261

            Response = new Field[] 
            {
                new Field() { Name = "rows", Type = "List<object>"},
                new Field() { Name = "more", Type = "bool" },
                new Field() { Name = "next_key", Type = "string" } // add this line
            },
            GenericResponse = new Field[] 
            {
                new Field() { Name = "rows", Type = "List<TRowType>"},
                new Field() { Name = "more", Type = "bool" },
                new Field() { Name = "next_key", Type = "string" } // add this line
            }
3
  • If I set lower_bound and upper_bound with the value "", it returns the first 10 records, whereas I need the latest or last 10 records. So, I can get them by lower_bound="0" and upper_bound="-9". This is solved for the primary keys of type integer. Can you help more with the key type name? How to get the latest records and set the lower_bound for the next 10 records?
    – Varsh
    Commented Apr 16, 2021 at 6:41
  • next_key is not returned by GetTableRows in API.
    – Varsh
    Commented Apr 16, 2021 at 7:36
  • @Varsh upper_bound is the upper boundary value of primary key, not item's index. As you know primary key is uint64_t, so '-9' doesn't make sense here. With reverse = True, you can get last 10 items without lower_bound and upper_bound.
    – conr2d
    Commented Apr 17, 2021 at 3:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.