I have output, like:
[ { "serviceType": "MOVE", "directionCost": { "6ce50eb2-66cc-4581-a0fa-896454312ac7": 7000, "31a5d10d-db67-45d2-8efc-5b3f210a3bc0": 9265, "737212d9-cc3d-45bf-8c5e-43cad8f2f346": 8773 }, "id": "3c951dd2-c515-4189-9b78-0390b5c47d9d", "createdOn": "2021-04-05T20:14:29.817Z" }, { "serviceType": "MOVE", "directionCost": { "6b1f74b4-7e0b-4aef-aa2c-eee89f2aa039": 2639, "1be99c1f-64ec-43da-a723-74abe60d4d15": 4824, "cff4791b-514a-4c71-b409-375e24cc0751": 3818 }, "id": "7c7b59ae-306b-455c-bcb0-3690cdbc6cb2", "createdOn": "2021-02-08T09:10:29.83Z" }, { "serviceType": "MOVE", "directionCost": { "77074837-7ec3-4fbe-8c68-ff4f0f6c76a5": 2175, "c9c9259b-c010-4e1b-9303-be49eadcdfc9": 4404, "d8ccc562-6648-4683-b6b1-4061b3b4a2ef": 3271 }, "id": "e182fcbc-461d-447b-9239-1344e3f4f211", "createdOn": "2021-04-22T13:45:17.282Z" } ]
I try to write a query, that enables me to get output with the first minimal directionCost only like:
[ { "serviceType": "MOVE", "directionCost": { "6ce50eb2-66cc-4581-a0fa-896454312ac7": 7000 }, "id": "3c951dd2-c515-4189-9b78-0390b5c47d9d", "createdOn": "2021-04-05T20:14:29.817Z" }, { "serviceType": "MOVE", "directionCost": { "6b1f74b4-7e0b-4aef-aa2c-eee89f2aa039": 2639 }, "id": "7c7b59ae-306b-455c-bcb0-3690cdbc6cb2", "createdOn": "2021-02-08T09:10:29.83Z" }, { "serviceType": "MOVE", "directionCost": { "77074837-7ec3-4fbe-8c68-ff4f0f6c76a5": 2175 }, "id": "e182fcbc-461d-447b-9239-1344e3f4f211", "createdOn": "2021-04-22T13:45:17.282Z" } ]
I try to write my query like:
var finalResults = baseService.Where( .Select(x => x.DirectionCost.FirstOrDefault(el => el.Value == x.DirectionCost.Values.Min()));
but have output in a format like:
[ { "key": "5f099185-b9fc-4ce9-b8bd-79d2ad6470d6", "value": 16443 }, { "key": "51ea3e7b-92b6-4cd9-a0f8-413f105c1ee0", "value": 9844 }, { "key": "6622409a-f767-4268-ae3a-69cb1cd6bd30", "value": 10695 } ]
But I need other information also. Could you help me?