示例#1
0
        private IQueryable <VideoMetricPersona> MetricsByPersona(DateTime start, DateTime end, ApplicationDbContext context, Tag[] filters, ArchiveMode archive)
        {
            var videoList = context.ApplicationVideos.AsQueryable();

            return(from v in ApplyFilters(context, videoList, filters, archive)
                   join vc in context.ApplicationVideoSourceCampaigns on v.Id equals vc.VideoId
                   join a in ApplySourcAdFilters(context, filters).ToList().AsQueryable() on vc.CampaignId equals a.CampaignId
                   join am in context.SourceAdMetrics.Where(am => (am.EventDate >= start && am.EventDate <= end)) on a.Id equals am.AdId
                   join aau in context.SourceAdSets on a.AdSetId equals aau.Id
                   join ap in context.ApplicationPersonaVersionSourceAdSets on aau.Id equals ap.AdSetId into AdSetPersonaVersions
                   from ap in AdSetPersonaVersions.DefaultIfEmpty()
                   join pv in context.ApplicationPersonaVersions on ap.PersonaVersionId equals pv.Id into PersonaVersions
                   from pv in PersonaVersions.DefaultIfEmpty()
                   join p in context.ApplicationPersonas on pv.PersonaId equals p.Id into Personas
                   from p in Personas.DefaultIfEmpty()
                   select new VideoMetricPersona()
            {
                VideoId = v.Id, Metric = am, Persona = p.Name ?? "None", Platform = a.Platform
            });
        }