Only do Where condition if a value is passed in

后端 未结 4 561
隐瞒了意图╮
隐瞒了意图╮ 2021-01-24 06:22

I have the following LINQ statement that does on where on the date and a LabID.

I\'m passing in a list of LABS and a date, however

4条回答
  •  感动是毒
    2021-01-24 06:54

    What we do is something like (l.reportingPeriod == reportingPeriod || reportingPeriod == null) So you check to see if the parameter is its default meaning it hasnt been used or if there is something there check it against the database.

提交回复
热议问题