string[] searchArray = {"WORD1","WORD2"};
var vars = db.vars.Where(v => searchArray.Contains(v.word)).Select(v => v.id);
var xrefs = dr.xref.Where(x => vars.Contains(x.wordid)).GroupBy(x => x.itemid)
.Select(g => new
{
ItemId = g.Key,
Score = g.Sum(s => s.weight),
CountItemId = g.Count()
})
.OrderByDescending(r => r.CountItemId)
.ThenByDescending(r => r.Score)
.Take(20)
.Select(o => o.ItemId);
var items = db.Items.Where(i => xrefs.Contains(i.id));