C# Getting multiple column when using a SELECT on an Array.

How can I return multiple columns to the uniqueitems array below?  The nodeValues array has 2 columns; attributeTtitle and attributeURL.   How can I get both of these columns in uniqueitems array.    Right now the statement below only returns the attributeTtitle column.  

var uniqueItems = nodeValues.SelectMany(item => item.value).Select(val => val.attributeTtitle).Distinct();

Example of data from nodevalues:

attributetitle       attributeURL
Color                     Step://attribute?id="921_color"
Size                       Step://attribute?id="100_size"
tmajor99Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Fernando SotoRetiredCommented:
What type does the collection nodeValues hold? Please show the definition of the object held in the collection.

What do you want the return of the query to look like?
0
it_saigeDeveloperCommented:
Try this:
var uniqueItems = nodeValues.SelectMany(item => item.value).Select(val => new { Title = val.attributeTtitle, URL = val.attributeURL}).Distinct();

Open in new window

Example -
using System;
using System.Collections.Generic;
using System.Linq;

namespace EE_Q28691823
{
	class Program
	{
		static List<Person> people = new List<Person>() 
		{ 
			new Person() { ID = 1, Name = "Jim", Birthday = new DateTime(2010, 1, 1), Gender = Gender.Male }, 
			new Person() { ID = 2, Name = "Julie", Birthday = new DateTime(2011, 1, 1), Gender = Gender.Female }, 
			new Person() { ID = 1, Name = "Jim", Birthday = new DateTime(2010, 1, 1), Gender = Gender.Male }, 
			new Person() { ID = 2, Name = "Julie", Birthday = new DateTime(2011, 1, 1), Gender = Gender.Female }, 
			new Person() { ID = 5, Name = "Vance", Birthday = new DateTime(2010, 1, 1), Gender = Gender.Male }, 
			new Person() { ID = 6, Name = "Vanessa", Birthday = new DateTime(2011, 1, 1), Gender = Gender.Female } 
		};

		static void Main(string[] args)
		{
			Console.WriteLine("Full list");
			foreach (var person in people)
				Console.WriteLine("{0} [{1}] is a {2}", person.Name, person.ID, person.Gender);

			Console.WriteLine();
			Console.WriteLine("Distinct list");
			var p1 = people.Select(p => new { Moniker = p.Name, EntryDate = p.Birthday }).Distinct();
			foreach (var person in p1)
				Console.WriteLine("{0} was born on {1}", person.Moniker, person.EntryDate);

			Console.ReadLine();
		}
	}

	class Person
	{
		public int ID { get; set; }
		public string Name { get; set; }
		public DateTime Birthday { get; set; }
		public Gender Gender { get; set; }
	}

	enum Gender : int
	{
		None = 0,
		Male = 1,
		Female = 2,
		Unknown = 3,
		Undeclared = 4
	}
}

Open in new window

Produces the following output -Capture.JPG
-saige-
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.