Original query:
I have collection with element(let it be only one in collection)
{
"_id" : ObjectId("595e083dfe3d9236b8c178bf"),
"Version" : NumberInt(0),
"CompanyId" : ObjectId("579a15affe3d910de824ea00"),
"TenderAlertLotStateList" : [
{
"TenderLotId" : ObjectId("595e077bfe3d9236b8c175be"),
"ClientResponseDescription" : {
"ResponseBy" : null,
"ResponseAt" : null,
"ClientResponseType" : NumberInt(2),
"TenderAlertRejectionReasonId" : null
},
"TenderAlertStatus" : NumberInt(0)
},
{
"TenderLotId" : ObjectId("595e0765fe3d9236b8c1759f"),
"ClientResponseDescription" : {
"ResponseBy" : null,
"ResponseAt" : null,
"ClientResponseType" : NumberInt(2),
"TenderAlertRejectionReasonId" : null
},
"TenderAlertStatus" : NumberInt(0)
},
{
"TenderLotId" : ObjectId("595e074bfe3d9236b8c1757b"),
"ClientResponseDescription" : {
"ResponseBy" : null,
"ResponseAt" : null,
"ClientResponseType" : NumberInt(2),
"TenderAlertRejectionReasonId" : null
},
"TenderAlertStatus" : NumberInt(0)
},
{
"TenderLotId" : ObjectId("595e06eefe3d9236b8c173a9"),
"ClientResponseDescription" : {
"ResponseBy" : "apetruc1@gmail.com",
"ResponseAt" : ISODate("2017-07-06T09:54:52.437+0000"),
"ClientResponseType" : NumberInt(1),
"TenderAlertRejectionReasonId" : null
},
"TenderAlertStatus" : NumberInt(2) //<<it is TenderAlertStatus.Archived!!!
}
]
}
3.
GetAllFor().Where(a => a.CompanyId == clientCompanyId && a.TenderAlertLotStateList.Any(s => !a.TenderAlertLotStateList.All(s => s.TenderAlertStatus == TenderAlertStatus.Archived))).ToList()
Even throws error. Inncorrect!
It means "!=" operator does not work properly for internal collection
Note GetAllFor() returns IQueryable<of the class>
Updated description:
1. We do not support difficult All queries if there is an approach to make the same logic via Any.
2. The above example will not compile as syntax error: Any and All methods have the same parameter "s" in the same code scope.
So, the following query should be supported instead of the original one:
GetAllFor().Where(a => a.TenderAlertLotStateList.Any(s => a.TenderAlertLotStateList.Any(s2 => s.TenderAlertStatus != 2))).ToList();
- is related to
-
CSHARP-2012 != operator works incorrect for internal collection
-
- Closed
-