saurav.rox
New member
- Joined
- Apr 13, 2023
- Messages
- 3
- Programming Experience
- 1-3
I have an entity called Account which contains a column called AccountType which is an enum with multiple enum items such as Principal, Student, Staff, etc. So, I am trying to search for a string that matches any of these enums and return the list of matching Accounts.
Here is how I am trying:
However, the second line throws an error saying: Cannot implicitly convert type 'bool' to 'System.Linq.IQueryable'
AccountType Enum is declared as:
Any help on how to search for matching strings in Enum and return the result list? Please let me know for any further clarification.
Thank you,
Here is how I am trying:
C#:
var accQueryList = _context.Accounts.Where(x => true);
accQueryList = Enum.GetNames(typeof(AccountTypeEnum)).Contains(parameters.Filter.ToString().ToLower()); //Error is seen here
var items = _mapper.Map<List<AccountVM>>(await accQueryList.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToListAsync());
However, the second line throws an error saying: Cannot implicitly convert type 'bool' to 'System.Linq.IQueryable'
AccountType Enum is declared as:
C#:
namespace Services.Common.Enums.Account
{
public enum AccountTypeEnum
{
Principal, Student, Staff
}
}
Any help on how to search for matching strings in Enum and return the result list? Please let me know for any further clarification.
Thank you,
Last edited by a moderator: