Reputation: 2591
Im having trouble with my multiple AND/OR LINQ query
Current Error is "&& cannot be applied to bool and datetime"
Is there a better way to do this? I think I may need to check for nulls on some of those too
Thanks
(d.Development != 1 && d.Deleted != 1 && d.Stock != 1) && (d.DecommissionDate = Convert.ToDateTime("1900-01-01"))
Upvotes: 0
Views: 97
Reputation: 14870
The second part doesn't convert to a boolean:
(d.DecommissionDate = Convert.ToDateTime("1900-01-01"))
=
is an assignment operator. When it is done, it will try to compare a boolean to a DateTime
. If your intent is to compare the DecommissionDate
, use ==
instead. If you really want to assign it, you need to do it on a separate occasion.
Upvotes: 7
Reputation: 22794
You got a small typo: you used the single equals (=
, used for assignment) instead of the double equals (==
, equality).
Here's the fix:
d.DecommissionDate == Convert.ToDateTime("1900-01-01")
Upvotes: 2