Using Where in Entity FrameWork Query Clause

Marc Jeeves 121 Reputation points
2021-12-12T15:59:45.64+00:00

Morning,

I have a simple SQLite Database Table with two rows of data one where IsCustom is 'false' and the other 'true' my query when i use '.Where(r => r.IsCustom == false).ToListAsync();' returns both rows and when the value is 'true' returns nothing.

Can somebody help

Thanks

Madaxe

CREATE TABLE Querys (
    Id       TEXT    PRIMARY KEY
                     NOT NULL,
    Name     TEXT,
    [Query]  TEXT,
    IsCustom BOOLEAN
);



public async Task<IEnumerable<QueryModel>> GetAllQuerys()
        {
            using (HideShowWidgetDBContext context = _hideShowWidgetDBContextFactory.CreateDbContext())
            {
                IEnumerable<QueryDTO> queryDTOs = await context.Querys
                    .Where(r => r.IsCustom == false).ToListAsync();

                //IEnumerable<QueryDTO> queryDTOs = await context.Querys.ToListAsync();
                return queryDTOs.Select(r => new QueryModel(r.Name,r.Query,r.IsCustom));
            }
        }


public class QueryDTO
    {
        [Key]
        public Guid Id { get; set; }
        public string Name { get; set; }
        public string Query { get; set; }
        public bool IsCustom { get; set; }
    }
Developer technologies .NET Entity Framework Core
{count} votes

Accepted answer
  1. Marc Jeeves 121 Reputation points
    2021-12-14T14:23:37.52+00:00

    Morning I figured it out this morning, the database values must be 1 or 0 not true and false, wood for the trees

    thanks

    Madaxe

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.