model isn't working as expected C#

Question

My model is getting data I need, but I'm not sure how to organize it in the way I need. I have it where the model pulls a team, and a player. The issue is when mapping my data to the model it gives me duplicate teams, and doesn't allow me to call players individually. essentially I have a new object for each player, but I want a new object for each team instead, and without duplicates. I also want each team to have a player property where I can pull an individual player.

public class Player
{
public string team { get; set; }
public string player { get; set; }
}

So in conclusion I need it to return an object that checks the data to see if the team is a duplicate. If it is then add the player to the team that currently exists. If it is a new team then create the team, and add the player.

Popular Answer

From the comments made on your question, I think the following may be helpful. However, for the record, none of this is best practice, and I can't professionally recommend other people do this. But it solves the issue you have with the constraints you're under.

If you just want to get the list of teams with no duplicates, you could do the following:

This will return a distinct list of teams. Essentially, if you want to get individual teams, and just pull through one player, you're going to have to manually go through your HashSet after you have built it up.

EDIT: Some information in the comments below the question itself have been removed (or I can't see them!) but alphamalle did mention that they do not have access to modify the stored procedure, hence my approach above.