Check null for list parameter in Dapper
Is there a way to check for null when the parameter type is an
IEnumerable? I know Dapper will translate the list parameter into a
parametrized query so I'm suspecting that's the reason why the list
parameter cannot be checked for null but I was wondering if there's a way
to achieve that behaviour.
The idea is to do something like this:
select * from Table1 where (@ids IS NULL OR id in @ids)
Right now that query throws SqlException with the message: Must declare
the scalar variable "@ids". Incorrect syntax near ')'.
No comments:
Post a Comment