This is my linq query.
var data =
(from obj in lstEventsDataForGrid
where obj.strDateCode.Contains(thisWeekend[0] == null ? "" : thisWeekend[0])
|| obj.strDateCode.Contains(thisWeekend[1] == null ? "$" : thisWeekend[1])
|| obj.strDateCode.Contains(thisWeekend[2] == null ? "$" : thisWeekend[2])
&& strArr.Contains(obj.strEventType.ToString().ToUpper())
orderby obj.dtmStartDate ascending
select obj).GroupBy(x => x.strEventCode)
.Select(y => y.First()).ToArray();
Expected Result
It should not come whether the strEventType is not in the strArr.
But it is coming even that type is not in the array.
Issue I noticed is if I remove one where condition i.e that obj.strDateCode.Contains(...) the other condition is working.
Where am I going wrong? Please suggest something!
||and&&without brackets - it's easy to get the wrong associations. Try bracketing it as you're expecting the logic to work.