首先sql使用参数 类似
select * from tabe1 where
( (condition =@condition and @condition is not null ) or @condition is null)
and ((request =@request and @request is not null ) or @request is null)
and ((datetime >=@starttime and @starttime is not null ) or @starttime is null)
and ((datetime <=@endtime and @endtime is not null ) or @endtime is null)