Reputation: 221
What I have right now is this:
var dividendItemsRecord = yearItem.GetType().GetProperties().Where(x => x.Name.Contains("Record"));
var dividendItemsPayable = yearItem.GetType().GetProperties().Where(x => x.Name.Contains("Payable"));
var dividendItemsCash = yearItem.GetType().GetProperties().Where(x => x.Name.Contains("Cash"));
var dividendItems = dividendItemsRecord.Concat(dividendItemsPayable)
.Concat(dividendItemsCash)
.ToList();
This is clearly not the way I would like to do it, I am wondering if anybody knows a way to do it in one step.
PS: The items found will never intersect
Upvotes: 0
Views: 45
Reputation: 353
The following should do it :
var listOfItems = yearItem.GetType().GetProperties().Where(x => x.Name.Contains("Record") || x => x.Name.Contains("Payable") || x => x.Name.Contains("Cash")).ToList();
Upvotes: 1
Reputation: 2924
You can join multiple conditions in one, with logical OR statement:
var dividend = yearItem.GetType().GetProperties().
Where(x => x.Name.Contains("Record") || x.Name.Contains("Payable") || x.Name.Contains("Cash"));
Upvotes: 2