UPD: I apologize for the misinformation, LINQ knowledge is not enough to make a valid request through realm. I got it a little late.
Suppose I have 2 tables: HistoryItem and Quest
HistoryItem inside has a Quest field and other data. In the Quest table there is a MaxRepeats field.
What I need to get: I need to get a list of quests, which is filtered by date + filtered by the number of entries of THIS QUEST inside HistoryItem.
In this case, I need to show the quest only if it has been completed <MaxRepeats times. That is, for each of the quests to make a subquery that calculates the number of HistoryItem-s in which this quest is recorded in the Quest field. How to do it?
So far, I just have to work out a random code because I do not understand how exactly this entry should look like in principle:
var history = _db.Realm.All<HistoryItem>().Where(a => a.Quest != null).GroupBy(a=>a.Quest); var tmp = _db.Realm.All<Quest>().Where(a => a.StartDate < startDayIsLessThan && a.EndDate > EndDateIsHigherThan); I found the subquery syntax. For example, the following query finds people who have more than 3 unvaccinated dogs:
realm.All<Person>() .Filter("SUBQUERY(Dogs, $dog, $dog.Vaccinated == false).@count > 3")
Quests.Where(q => q.MaxRepeats > HistoryItems.Count(h => h.Quest == q))- Andrew NOP