We help IT Professionals succeed at work.
Get Started
Troubleshooting Question

Why do I get duplicate values in this list?

Camillia asked
Last Modified: 2020-10-20
Can't be that hard. I'm changing the previous developer's code and running into this:

1. This class
 public class ShipmentStatusSearch //: SearchEntity
        public IList<string> ShipmentId { get; set; }

2. I have this method and I see this value for "ShipmentIds"
[HttpGet, Route("v1/shipmentsListStatus")]
        public PagedResponse<ShipmentStatus> ShipmentsListStatus([FromUri] string[] shipmentIds)
 var shipmentSearch= shipmentIds.Select(array => new ShipmentStatusSearch { ShipmentId = shipmentIds}).ToList

3. It gets to this line and now I see an array of 2 elements and each element has the two "shipmentId" repeated. Why is that? It shouldn't repeat it. It should be one element with 2 items in it. I don't why I get [1] element.

 var shipmentSearch= shipmentIds.Select(array => new ShipmentStatusSearch { ShipmentId = shipmentIds}).ToList();

Watch Question
Most Valuable Expert 2020
Most Valuable Expert 2018
This problem has been solved!
Unlock 1 Answer and 9 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant

An Experts Exchange subscription includes unlimited access to online courses.

Get Started
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE