daily pastebin goal
16%
SHARE
TWEET

Untitled

a guest Dec 17th, 2018 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var history = _db.Realm.All<HistoryItem>().Where(a => a.Quest != null).GroupBy(a=>a.Quest);
  2.  
  3. var tmp = _db.Realm.All<Quest>().Where(a =>
  4.                               a.StartDate < startDayIsLessThan &&
  5.                               a.EndDate > EndDateIsHigherThan);
  6.    
  7. var histCount = _db.Realm.All<HistoryItem>()
  8.         .GroupBy(h => h.Quest)
  9.         .Select(gr => new {Q = gr.Key, Count = gr.Count()});
  10.  
  11.     var result = _db.Realm.All<Quest>()
  12.         // сокращаем коллекцию до join
  13.         .Where(q => q.StartDate > start && q.EndDate < end) // todo: перепроверить условие
  14.         // join с группированной коллекцией элементов истории
  15.         .Join(histCount,
  16.             quest => quest.Id,
  17.             hCount => hCount.Q,
  18.             (quest, hCount) => new {Quest = quest, HCount = hCount.Count})
  19.         // фильтрация по условиям кол-ва элементов
  20.         .Where(it => it.HCount < it.Quest.MaxRepeats)
  21.         // выборка результата
  22.         .Select(it => it.Quest)
  23.         .ToList();
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top