Match collections with LINQ

I have a set of objects to which I would just like to add a new property. How to do this with LINQ?

+3
source share
3 answers
var a = from i in ObjectCollection select new {i.prop1, i.prop2, i.prop3, ..., newprop = newProperty}
+2
source

I do not think you can use pure LINQ. However, if you do so much in your code, you can do this work with reflection.

0
source

Why do you want to add additional property? Or, in other words, what are you going to do with this property when it is in your new IEnumerable source?

If you need it for data binding, I have a helper class that can help you.

0
source

Source: https://habr.com/ru/post/1696699/


All Articles