Hello I have this problem where I have this classes:
class numberOne
{
public long ID {get; set;}
public string Name {get; set;}
public string Names {get; set;}
}
class numberTwo
{
public long[] ID {get; set;}
public string Name {get; set;}
}
they will be list after.
So lets say that the data of those lists are like this
List<numberOne> numberOne = new List<numberOne>();
numberOne.Add(new numberOne() { ID = 1234 });
numberOne.Add(new numberOne() { ID = 1334 });
numberOne.Add(new numberOne() { ID = 1434 });
numberOne.Add(new numberOne() { ID = 1568 });
List<numberTwo> numberTwo = new List<numberTwo>();
numberTwo.Add(new numberTwo() { ID[] = 1234,1334 Name = "sam" });
numberTwo.Add(new numberTwo() { ID[] = 1434, Name = "paul" });
numberTwo.Add(new numberTwo() { ID[] = 1434, Name = "john" });
numberTwo.Add(new numberTwo() { ID[] = 1568, Name = "john" });
I need that the the data can be show like this:
ID | Name | Names
1234|sam |sam
1334|sam |sam
1434|paul |paul, john
1434|john |paul, john
1568|john |john
So far I have this of code:
foreach(var items in numberOne.ToList())
{
items.Name = numberTwo.Where(a => a.ID.Any(b => b == items.ID)).Select(a => a.Name).Distinct();
items.Names = string.Join(",", numberTwo.Where(a => a.ID.Any(b => b == items.ID)).Select(a => a.Name).Distinct);
in this line "items.Name = numberTwo.Where(a => a.ID.Any(b => b == items.ID)).Select(a => a.Name).Distinct();
" is where I receive the error CS0029