I have a piece of code:
IList<Opportunity> filteredOpportunityProperties = new List<Opportunity>();
List<LookupWithIntId> selectedProperties = opportunityFilter.PropertyTypes;
List<string> propertyTypes = selectedProperties.Select(item => item.Name).ToList();
opportunities.Where((item) =>
{
string productType = item.Properties[0].ProductType;
bool propertyMatch = propertyTypes.Any(propTypes => productType.Contains(propTypes));
if (propertyMatch) select item;
});
if the condition matches I want that item to be selected. However, I get the error:
Embedded statement cannot be a declaration or labeled statement
Any suggestions!
In your where clause, change this line:
if(propertyMatch) select item;
To this:
return propertyMatch;
The where clause will return the item if the predicate result is true, so you just need to return the boolean result.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.