I have a stored procedure with a left join that returns something like this:
name1 car1
name1 car2
name1 car3
name2 car1
name3 null
name4 null
I need to store this result in an object like this:
class Person
{
string Name;
List<string> Cars;
}
What is the best way to do this? Either directly in the stored procedure or in code after retrieving the query result.
That I do now is once I have the result from db to iterate over it and add the name and its list of cars c#to another object if name is not already there.
Is there a better solution to this?