Dileep Namburu
Dileep Namburu

Reputation: 161

ServiceStack PocoDynamo C# Query on Nested object property

Below is my dynamodb row object structure. Status, Calls are 1st level columns and Inside Calls, i have nested data.

Record
      ->Status : 0
      ->Calls
             -[0]:CapIndex : 5
             -[1]:CapIndex : 0

What is the scan query in Servicestack and I need to fetch rows with Status=0 and if any of the Calls having CapIndex=0

I tried the below but it was throwing exception

dynamoClient.FromScan<Cache>(x=>x.Status==0 && x.Calls.Any(y=>y.CapIndex == 0)).Exec()

Exception: variable 'x' of type 'Cache' referenced from scope '', but it is not defined

Any idea folks?

Upvotes: 1

Views: 197

Answers (1)

mythz
mythz

Reputation: 143284

You can't perform a server side query on a nested complex type, you would need to perform the nested complex type query on the client after executing the Dynamo DB Query, e.g:

var results = dynamoClient.FromScan<Cache>(x=>x.Status==0).Exec()
  .Where(x => x.Calls.Any(y=>y.CapIndex == 0)).ToList();

Upvotes: 2

Related Questions