0

I have two database table, DeviceCatalogue and SkuDetails. DeviceCatalogue has a one to many relationship with SkuDetails, since skudetails is an array. The issue is coming when i'm filtering skudetails based on prices.

enter image description here

for querying the database i'm using following predicate on DeviceCatalogue :

"Any skudetails.priceWithVat >= 1 And Any skudetails.priceWithVat <= 2000"

its basically returning me all the devices under this range. but the issue is that i need only those skudetails which is basically under that filter, but since the relationship in inverse it returning me all the skudetails with this range.

i try to use Subquery also but it is still no solution.

lets take a example of the issue.

IPhone6  <Devices>
- color -> Black , storage -> 64GB , Price 2000 <SkuDetail>
- color -> Black , storage -> 32GB , Price 1800 <SkuDetail>
- color -> White , storage -> 128GB , Price 2800 <SkuDetail>

i only required black 32gb as it is under this range but i'm getting all 3 of them. as im returning devices entity.

should i change my predicate to something else to get my respective result or im doing any thing wrong. or there is fault in overall architecture of database.

  • Did you try “skudetails.price >= 1 AND skudetails.price <= 2000”? I dont see any table with name SkuDetails in your image. – trungduc May 13 '18 at 17:21
  • yes i try skudetails.priceonvat on device catalogue . – Syed Faraz Haider Zaidi May 13 '18 at 18:24
  • Does the 'price' field your attempting to query exist on the DeviceCatalogueSkuDetails table? From your image this does not appear to be the case. It looks like you are attempting to query the 'price' field on DeviceCataloguePaymentOption, which would have the query path 'skuDetails.devicePaymentOption.price'. – richardpiazza May 14 '18 at 13:01
  • yes its a typo issue it was pricewithVat. i updated the question – Syed Faraz Haider Zaidi May 14 '18 at 18:41

0 Answers0