forum

Home / DeveloperSection / Forums / Where clause not giving the desired value in Linq

Where clause not giving the desired value in Linq

Anonymous User 1982 17-Nov-2014

I’m attempting to write a search routine and part of it includes the following code:

string searchValue =Server.HtmlEncode(RadSearchBox.Text.ToLower());
 
var injurySearchList = (from i in injuryObj
                        where i.IsDeleted == false &&                        (
                            i.ResultOther == true ?"ResultOther".ToLower().Contains(searchValue) :i.IncidentID.ToString().Contains(searchValue)
                            || i.BodyPartHead == true ?"BodyPartHead".ToLower().Contains(searchValue) : i.IncidentID.ToString().Contains(searchValue)
                        )
                        select i.IncidentID).ToList();

I’m unable to search the bit values for a string.I use the ternary operator to evaluate if it’s true,If the bit value is false, I’d prefer to exclude that line from the WHERE clause but was unable to come up with any clever ideas


Please suggest me


Updated on 17-Nov-2014
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By