(Fees is a collection of Fee objects.)
If the Fees collection is empty, I want to assign a default value of 0 to FeeValue.
Below is what I currently do. However, I’d prefer to not new up an instance of Fee. What are some alternative ways to write this? Thanks!
from w in Widgets
select new {
FeeValue = w.Fees.DefaultIfEmpty(new Fee()).First().Value, // Value is a Double
};
Your questions is a bit confusing, but I think I know what you’re asking…
Something like this: