Please use the Insert Code Editor
tool to insert code into your posts so we can copy your code.
The problem is with your call to usp_OrderDetails
. Let's verify that. Put a breakpoint on that call. Verify item.OrderID
has the value you expect. Then F10 to execute the call. When the call returns view orderDetailList
in the debugger (if using VS 2022 then use the IEnumerable visualizer). Check each of the items that were returned. Do they all have the same order detail? If they do then your sproc is returning duplicate data. I could see a potential for EF mappings to be wrong but since you're just using SQL here then I would find that odd.
Another possibility is that your orderHeader
property has logic in it that is messing things up. Since you didn't post it we can only assume it is an auto-property.
Finally, we are assuming you don't have objects referencing other objects here that could be causing problems. You're using a VM so we have no idea what it is doing. Try switching to a local variable temporarily and see if the problem goes away.