My brain fails at the request I need to configure.
I have a Cat object that has two (relevant) properties:
public virtual ICollection<Ribbon> Ribbons { get; set; }
public virtual ICollection<Trophy> Trophies { get; set; }
Both Ribbon and Trophy have an integer property named "UmbracoActivityId" Ribbons and trophies are not directly related to each other, but they are both related to cat and UmbracoActivity. Cats receive a ribbon for every “step” they complete in UmbracoActivity, and a trophy to complete all stages. They are very competitive cats :)
I need to do a count of cats that launched UmbracoActivity, but did not complete all the steps (did not receive the trophy).
In plain English: find all the great tapes where the cat that has the tape does NOT have a trophy with the same UmbracoActivityId as the UmbracoActivityId tape.
What I have in the code:
var ribbons = db.Ribbons
.Where(ribbon => db.Cats.Find(ribbon.CatId)
.Trophies.Any(trophy => trophy.UmbracoActivityId == ribbon.UmbracoActivityId));
I'm getting closer, but the .Any () statement is true if the tape has a trophy with the same UmbracoActivityId. I need the opposite. It may just switch "==" to "! =", But in this case the cat may have many trophies with a different UmbracoActivityId.
I need a converse statement somewhere to look for the opposite, but I'm not sure where to do it :(
Thanks in advance.
source
share