0

Please i need someone to help convert this query entity(c#) form.

select * 
from incident 
where Details like'%Help%' 
and status = 'Resolved' 
or details like '%Help%' and Status = 'Closed'

See what I tried

incident = incident.Where(s => s.Details.ToUpper().Contains(SearchParam.ToUpper()));
4
  • 1
    Are you 100% clear on which conditions of your WHERE clause (in your SQL statement) get combined how? I have a feeling you might want something else than what you really get right now... Commented Jun 17, 2012 at 15:53
  • Incidentally, you're looking to express this query in LINQ. EF is just your persistence framework. Have you looked into LINQPad? Commented Jun 17, 2012 at 16:00
  • 1
    Why isn't your query WHERE Details LIKE '%Help%' AND [status] IN ('Resolved', 'Closed');? Mixing AND and OR can be quite confusing, and repeating the same clause multiple times is wasteful. IMHO. Commented Jun 17, 2012 at 16:11
  • What i want is a query that will extract all closed and resolved incident from the incident table based on the input criterial provided by the user. the input is the detail field. Commented Jun 17, 2012 at 16:14

1 Answer 1

2
incident = incident.Where(s => s.Details.ToUpper().Contains(SearchParam.ToUpper()) 
              && (s.Status == "Resolved" || s.Status == "Closed"));
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.