Method that accepts two Dal objects =>> Method(DalFirst[] source1, DalSecond[] source2):
source1.Select(
src => new DataExmaple()
{
Id = src.Id,
...
AdditionalField = source2.Select(x => x.Field).ToString()
}
I get the output name as just type "System.Linq.Enumerable SelectArrayIterator`2[....". With FirstOfDefault => it turns out, but the same values are everywhere.
CodePudding user response:
There is no default string representation of a collection. You'd need to specify how you want the data to render as a string. For example, if you want each value separated by a comma (or any other delimiter) then you can join the collection values with String.Join
:
AdditionalField = String.Join(",", source2.Select(x => x.Field))
CodePudding user response:
The problem is this expression:
AdditionalField = source2.Select(x => x.Field).ToString()
At this point, source2
is still the entire DalSecond[] source2
array. You need to do something to map each source1
item to the specific matching source2
value(s). I could give you more, but there's not enough information in the question yet to infer what you really want to do here.