Okay, so I have got this JSON object called "Faults"
"Faults":[{"RoomId":1,"ElementId":173,"FaultTypeId":1,"Count":1,"Remark":""},{"RoomId":3,"ElementId":211,"FaultTypeId":7,"Count":1,"Remark":""},{"RoomId":4,"ElementId":173,"FaultTypeId":1,"Count":1,"Remark":""}]
Faults object shown in debugger:
Now I need to check if a room contains a Fault by using he RoomId
.
The code I'm using for this is:
Enumerable.From(audit.Rooms).ForEach(function(room, index) {//√
var containsFaults = '';
//room.Id is ALWAYS filled, it can't be null
var test1 = faults.Select("$.RoomId==" + room.Id).Count();
var test2 = faults.Select("$.RoomId==" + room.Id);
if (faults.Select("$.RoomId==" + room.Id).Count() > 0) {
containsFaults = '√';
}
But when I'm executing this code im getting the following results...
Why won't it just return the fault's from my object with the matching RoomId
? I'm sure the Id's do match. What am I doing wrong here, i'm getting really stuck over this...
Thanks in advance!