{
"Id": 1234,
"CommentType": "project",
"EntityReferenceId": "1345-154-154",
"Members": [{
"MemberId": "1354",
"Name": "a",
"Email": "[email protected]"
}],
"Threads": [{
"Id": "233",
"UserReferenceId": "32343",
"UserName": "433434",
"CommentByUserType": "Agent",
"Content": "dfdfdsfs sfdf sdf",
"PostedDate": "0001-01-01T00:00:00",
"Active": true,
"Attachment": [{
"AttachmentName": "ad",
"AttachmentUrl": "http://fdf.jpg"
}]
},
{
"Id": "233",
"UserReferenceId": "32343",
"UserName": "433434",
"CommentByUserType": "Agent",
"Content": "dfdfdsfs sfdf sdf",
"PostedDate": "0001-01-01T00:00:00",
"Active": false,
"Attachment": [{
"AttachmentName": "ad",
"AttachmentUrl": "http://fdf.jpg"
}]
}]
}
I am using MongoDb to linq, This is my Comment" object format.for each Project there is a comment object.Each Comment object contains a list of "Threads"(you can see this above example).I want to load the "Comment" object with all thread which is Active("Active": true)
var result = _context.Comments
.AsQueryable()
.Where(x => x.EntityReferenceId == EntityReferenceId &&
x.CommentType == Type &&
x.Threads.Any(z=>z.Active==true))
.FirstOrDefault();
I used this query but it loading all threads if Any thread have "Active" value is true.
x.Threads.Any(z=>z.Active==true)
returns only bool values.I need a solution please
AnywithWhereand see the result?