I am not sure how to convert this simple foreach to linq.
It seems pretty easy, but I keep getting compile errors?
var createAccount = from TransactionDetail td in transactionDetails
Where
td.ResponseType == ResponseType.SUCCESS AND
td.RequestType == RequestType.CREATE_ACCOUNT
SELECT true;
/* trying to convert this */
bool createAccount = true;
foreach(TransactionDetail td in transactionDetails )
{
if (td.RequestType == RequestType.CREATE_ACCOUNT)
{
if (td.ResponseType == ResponseType.SUCCESS)
{
createAccount = false;
}
}
}
If all you want is a boolean result, you don’t need
whereorselect. Use theAnymethod: