phnx47 / dapper-repositories

CRUD for Dapper
MIT License
663 stars 202 forks source link

Predicate can't parse #401

Closed minik42 closed 3 months ago

minik42 commented 3 months ago

Hi, I'm getting an error: predicate can't parse. This is my code:

public IEnumerable GetMessages(int recipientId, bool? isRead)
{
    var results = SetLimit(1, 10)
        .FindAll(x => x.Recipient_Id == recipientId && (isRead == null || x.IsRead == isRead));
    return results;
}

Is there any way to apply next conditions if for example value is not null as above?

phnx47 commented 3 months ago

@minik42 Hi, problem with this part isRead == null, try something like this

public IEnumerable GetMessages(int recipientId, bool? isRead)
{
    var results = SetLimit(1, 10)
        .FindAll(x => x.Recipient_Id == recipientId && x.IsRead == isRead);
    return results;
}