EF Core 2.0 System.NotSupportedException: could not parse expression

143 views Asked by At

I have been getting lots of intermittent errors like below in my API (.NET Core 2.0) code that is calling a business logic (.NET Standard) which is calling SQL Server database using EF Core 2.0.

Can anyone please help me where to look at? This started happening 4 days back out of the blue where no new code has been added.

Is there any new Microsoft patch that has come in recently that might be causing this?

EF Core Query:

public Repository(IDataContextAsync context)
    {
        _context = context;

        if (context is DbContext dbContext)
        {
            _dbSet = dbContext.Set<TEntity>();
        }
    }

public IQueryable<TEntity> Queryable()
    {
        return _dbSet;
    }

public async Task<int> GetActiveSystemUserIdByName(string userName)
    {
        return await
            Queryable()
                .Where(s => s.UserName == userName && (s.IsActive ?? true))
                .Select(s => s.SystemUserId)
                .FirstOrDefaultAsync();
    }

System.NotSupportedException: Could not parse expression. Could not parse expression

'value(Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryable`1[Entities.Order.SystemUser]).Where(s => ((s.UserName == __userName_0) AndAlso (s.IsActive ?? True))).Select(s => s.SystemUserId)':

This overload of the method 'System.Linq.Queryable.Select' is currently not supported.

0

There are 0 answers