nstrução @LINQ WHERE / ignorar condições
Preciso ignorar algumas ou todas as condições na instrução WHERE se o parâmetro for nulo ou vazio F.E:
Tenho uma consulta LINQ simples
var query = from x in context.a
where x.p == param1 && x.i == param2
select x;
Como posso ignorarx.p == param1
se param1 for nulo ou vazio?
Tentei isso
var query = from myLog in myContext.ApsValidationLogs
where (myLog.systemtype == comboBoxSystemType.SelectedItem.ToString() || string.IsNullOrEmpty(comboBoxSystemType.SelectedItem.ToString()))
&& (myLog.bankid == comboBoxBankId.SelectedItem.ToString() || string.IsNullOrEmpty(comboBoxBankId.SelectedItem.ToString())))
select myLog;
But got
Object reference not set to an instance of an object.
Caso o item da segunda caixa de combinação seja nulo. O que há de errado