---
title: "Where clause not giving the desired value in Linq"  
description: "Where clause not giving the desired value in Linq"  
author: "Anonymous User"  
published: 2014-11-17  
updated: 2014-11-17  
canonical: https://www.mindstick.com/forum/12620/where-clause-not-giving-the-desired-value-in-linq  
category: "linq"  
tags: ["linq"]  
reading_time: 1 minute  

---

# Where clause not giving the desired value in Linq

I’m attempting to write a [search](https://www.mindstick.com/articles/65368/best-smo-services-company-in-hyderabad-improve-search-rankings) [routine](https://yourviews.mindstick.com/audio/1242/the-importance-of-routine-in-achieving-success) 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](https://www.mindstick.com/forum/327/sum-textbox-values) for a [string](https://www.mindstick.com/articles/1527/string-split-in-c-sharp).I use the [ternary operator](https://www.mindstick.com/forum/12944/ternary-operator-in-razor-using-a-model) to evaluate if it’s true,If the bit value is false, I’d prefer to [exclude](https://www.mindstick.com/forum/1756/wpf-linq-a-collection-to-include-or-exclude-items) that line from the [WHERE clause](https://www.mindstick.com/interview/1909/when-do-you-use-where-clause-and-when-do-you-use-having-clause) but was unable to come up with any clever ideas\

\

[Please suggest](https://answers.mindstick.com/qa/43506/please-suggest-the-bathing-date-at-kumbh) me

## Replies

### Reply by Sumit Kesarwani

Hi Goti, try the below code:

```
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();
```


---

Original Source: https://www.mindstick.com/forum/12620/where-clause-not-giving-the-desired-value-in-linq

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
