Users Pricing

forum

home / developersection / forums / where clause not giving the desired value in linq

Where clause not giving the desired value in Linq

Anonymous User 2289 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


I am a content writter !


1 Answers

Markdown for AI

A clean, structured version of this page for AI assistants and LLMs.

Open .md