can some one tell what im doing wrong in my linq, basicall in the
operation test for a neither one of the values have a fail and its
jumping in the case, im look for any tests that has value of fail
and
it has a value of fail jump into the case, for some some reason its
jumping into the case when all tests has a value of pass, i think its
the count > 0 is probably why, what to use instead of the .count
if (Operation.Tests.Select(t => ((t.StatusByTest != null) && (t.StatusByTest.Equals("FAIL")))).Count() > 0)
{
Operation.StatusByOp = "FAIL";
}
Loading
David SmithPosted Oct 24, 2010, 6:04 PM
I started it off but , I almost made it to the finish line.
I need help with the linq below.
var items = from list in eventLogList.EtagsThatOccur
group list by list.OpDateTime
into g
select new { Date = g.Key, Test = g.Select(t => t.TestName).First(), Etag = g.Select(t => t.etags).First(), Occurance = g.Count() };
Date : 10/13/10
Test: Oranges
[0] 001
[1] 001
Date: 10/14/10
Test: Greens
[0] 002
[1] 003
Date: 10/15/10
Test: Peaches
[0] 003
[1] 003
Date:10/16/10
Test: Red
[0] 003
[1] 002
This is my output below im trying to do a linq to sum up the occurences by datetime , test name, the actual code that occured, and the occurences of the code
Date : 10/13/10 Test : Oranges Code: 001 occurences: 2
Date : 10/14/10 Test : Greens Code: 002 occurences: 1
Date : 10/14/10 Test : Greens Code: 003 occurences: 1
Date : 10/15/10 Test : Peaches Code: 003 occurences: 2
Date : 10/16/10 Test : Red Code: 003 occurences: 1
Date : 10/16/10 Test : Red Code: 002 occurences: 1
David SmithPosted Oct 24, 2010, 5:41 PM
Suthish NairPosted Oct 24, 2010, 4:03 AM
1. if(Operation.Tests.Any(t => t.StatusByTest != null && t.StatusByTest.Equals("FAIL"))) { }
2. if(Operation.Tests.Where(t => t.StatusByTest != null && t.StatusByTest.Equals("FAIL")).Count()) { }