The xml elements are variable depending on some conditional. I need to initialize an instance with a different element, based on the value of some other element.
var result = (from name in names
select new MyName
{
name.First = name.Type = Fracais ? name.PreNom : name.First,
name.Last
}
Any ideas?
What you have is almost right. I had to guess the enums and members as you don’t provide the other classes:
You can have pretty much any expression, including function calls, in a linq query, so testing values and mutating them on the fly is perfectly acceptable.