help with linq query
Posted
by Luis
on Stack Overflow
See other posts from Stack Overflow
or by Luis
Published on 2010-03-08T22:59:41Z
Indexed on
2010/03/08
23:06 UTC
Read the original article
Hit count: 331
LINQ
Hi, i am trying to get some data, but i dont know how can i do a if in linq, this 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
the optype is a Int, the idState is a Int, end is a datetime, start is a datime
what i am trying to do is, if those aren't null they add to the query function, so i can get all data together
© Stack Overflow or respective owner