See the following example, now I need to check if UserService.GetByUserID() is null then return String.Empty. How can I still do this in one line?
var benefits = customerBenefits.Select(n =>
new CustomerBenefit(n.BenefitID,
n.AddedByUserID.HasValue
? UserService.GetByUserID(n.AddedByUserID.Value).DisplayName
: n.AddedByAgentID, n.Reason);
CustomerBenefit. Do you mean you need it for one of the constructor arguments? It would really help if you'd give more information.AddedByAgentIdinstead of a display name if there isn't anAddedByUserId? Don't you want to look up the agent's display name?