I am trying to get some data, but I don’t know how to do it if in linq, here is how I am trying to do
from so in db.Operations
where ((opType!= "0" ? so.Operation == int.Parse(opType) : false)
&& (idState!=0 ? so.State == idState : false)
&& (start != null ? so.StartDate == start : false)
&& (end !=null ? so.EndDate == end : false))
select so
Optip is Int, idState is Int, end is date-time, beginning is time
what am I trying to do, if they are not null, they add to the query function, so I can collect all the data
for example: in C # code
if((opType!= "0")
where (so.Operation == int.Parse(opType)
if(idState!=0)
where (so.Operation == int.Parse(opType) && so.State == idState
.......
so if it is not empty, this sentence in this sql query (TRUE part, I do not want to use the false part), add it to the place, so I can look for all parameters that are not null or 0
source
share