当前位置: 首页>>代码示例>>C#>>正文


C# IQueryable.SelectMany方法代码示例

本文整理汇总了C#中IQueryable.SelectMany方法的典型用法代码示例。如果您正苦于以下问题:C# IQueryable.SelectMany方法的具体用法?C# IQueryable.SelectMany怎么用?C# IQueryable.SelectMany使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IQueryable的用法示例。


在下文中一共展示了IQueryable.SelectMany方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ApplyFilters

        internal static IQueryable<Event> ApplyFilters(GetReportDataRequest request, IQueryable<Event> query)
        {
            query = ApplyKeywordFilter(request, query);
            query = ApplyStartDateFilter(request, query);
            query = ApplyEndDateFilter(request, query);
            query = ApplyTopicFilter(request, query);
            query = ApplyTypeFilter(request, query);
            query = ApplyPresenterFilter(request, query);
            query = ApplyContactNameFilter(request, query);
            query = ApplyStatusFilter(request, query);
            query = ApplyRegistrationDateFilter(request, query);

            //Filter events based on event occurrence criteria
            var eventsOccQuery = query.SelectMany(ev => ev.EventOccurrences);
            eventsOccQuery = FilterByOccurrenceDate(request.OccurrenceStartDate, request.OccurrenceEndDate, eventsOccQuery);
            eventsOccQuery = FilterByCustomLocation(request.CustomLocation, eventsOccQuery);
            query = query.Where(q => q.EventOccurrences.Intersect(eventsOccQuery).Any());

            return query;
        }
开发者ID:rickeygalloway,项目名称:Test,代码行数:20,代码来源:ReportHelper.cs

示例2: BuildSuperJetInfo

 /// <summary>
 /// Build the jet info extra class from a regular event.
 /// </summary>
 /// <param name="background"></param>
 /// <returns></returns>
 /// <remarks>
 /// TODO: Track quality cuts, not just track and pt
 /// </remarks>
 public static IQueryable<JetInfoExtra> BuildSuperJetInfo(IQueryable<recoTree> background)
 {
     return background
         .SelectMany(ev => ev.Jets.Where(j => IsGoodJet.Invoke(j)).Select(j => CreateJetInfoExtra.Invoke(ev, j)));
 }
开发者ID:gordonwatts,项目名称:JetCutStudies,代码行数:13,代码来源:JetInfoExtra.cs

示例3: GetPendingConfirmation

 private IQueryable<tblDocument> GetPendingConfirmation(IQueryable<tblDocument> orders)
 {
     IQueryable<Guid> ids = orders
         .SelectMany(s => s.tblLineItems)
         .Where(s => s.LineItemStatusId == (int) MainOrderLineItemStatus.New)
         .Select(t => t.tblDocument.Id).Distinct();
     orders = orders.Where(s => ids.Contains(s.Id));
     return orders;
 }
开发者ID:asanyaga,项目名称:BuildTest,代码行数:9,代码来源:MainOrderRepository.cs

示例4: GetBackOrder

 private IQueryable<tblDocument> GetBackOrder(IQueryable<tblDocument> orders)
 {
     IQueryable<Guid> ids = orders
         .SelectMany(s => s.tblLineItems)
         // .Where(s => s.LineItemStatusId == (int)MainOrderLineItemStatus.Approved)
         .Select(t => t.tblDocument.Id).Distinct();
     IQueryable<Guid> withbackorder = _ctx.tblDocument
         .Where(p => p.Id != p.OrderParentId.Value)
         .SelectMany(s => s.tblLineItems)
         .Where(s => s.LineItemStatusId == (int) MainOrderLineItemStatus.Confirmed)
         .Where(p => ids.Contains(p.tblDocument.OrderParentId.Value))
         .Select(t => t.tblDocument.OrderParentId.Value).Distinct();
     orders = orders.Where(s => withbackorder.Contains(s.Id));
     return orders;
 }
开发者ID:asanyaga,项目名称:BuildTest,代码行数:15,代码来源:MainOrderRepository.cs

示例5: GetOrderLossSale

        private IQueryable<tblDocument> GetOrderLossSale(IQueryable<tblDocument> orders)
        {
            IQueryable<Guid> ids = orders
                .SelectMany(s => s.tblLineItems)
                .Select(t => t.tblDocument.Id).Distinct();
            IQueryable<Guid> withlosssale = _ctx.tblDocument
                .SelectMany(s => s.tblLineItems)
                .Where(s => s.LostSaleQuantity > 0)
                .Where(p => ids.Contains(p.tblDocument.OrderParentId.Value))
                .Select(t => t.tblDocument.OrderParentId.Value).Distinct();
            orders = orders.Where(s => withlosssale.Contains(s.Id));

            return orders;
        }
开发者ID:asanyaga,项目名称:BuildTest,代码行数:14,代码来源:MainOrderRepository.cs

示例6: GetRejected

        private IQueryable<tblDocument> GetRejected(IQueryable<tblDocument> orders)
        {
            IQueryable<Guid> ids = orders
                .SelectMany(s => s.tblLineItems)
                .Select(t => t.tblDocument.Id).Distinct();
            IQueryable<Guid> withRejected = _ctx.tblDocument
                .Where(s => s.DocumentStatusId == (int) DocumentStatus.Rejected)
                .SelectMany(s => s.tblLineItems)
                .Where(p => ids.Contains(p.tblDocument.OrderParentId.Value))
                .Select(t => t.tblDocument.OrderParentId.Value).Distinct();
            orders = orders.Where(s => withRejected.Contains(s.Id));
            return orders;

        }
开发者ID:asanyaga,项目名称:BuildTest,代码行数:14,代码来源:MainOrderRepository.cs

示例7: TrainingIQueriable

        /// <summary>
        /// Filter the events correctly for signal or background and build the
        /// training data.
        /// </summary>
        /// <param name="events"></param>
        /// <param name="isSignal"></param>
        /// <returns></returns>
        private static IQueryable<TrainingData> TrainingIQueriable(IQueryable<recoTree> events, bool isSignal)
        {
#if false
            var allJets = from e in events
                          from j in e.Jets
                          where j.pT > 30.0 && Abs(j.eta) < JetEtaLimit
                          select new TrainingData()
                          {
                              logR = j.logRatio,
                              lowestPtTrack = (from t in e.Tracks
                                               where DeltaR2(t.eta, t.phi, j.eta, j.phi) < 0.2 * 0.2
                                               orderby t.pT ascending
                                               select t).First()

                          };
#endif
            // Look at all jets
            var trainingDataSetJets = events
                .SelectMany(e => e.Jets.Select(j => new { Jet = j, Event = e }))
                .Where(j => j.Jet.pT > 30.0)
                .Where(j => Abs(j.Jet.eta) < CutConstants.JetEtaLimit);

            // If this is to be treated as signal, then look for the LLP to have
            // decayed in the right way.
            if (isSignal)
            {
                trainingDataSetJets = trainingDataSetJets
                    .Where(j => j.Jet.LLP.IsGoodIndex())
                    .Where(j => j.Jet.LLP.Lxy > 2 * 1000);
            }

            // Fill our training data that will eventually be turned into the training tree.
            var trainingDataSet = from j in trainingDataSetJets
                                  let trkList = from t in j.Event.Tracks
                                                where DeltaR2(t.eta, t.phi, j.Jet.eta, j.Jet.phi) < 0.04
                                                orderby t.pT ascending
                                                select t
                                  where trkList.Any()
                                  select new TrainingData()
                                  {
                                      logR = j.Jet.logRatio,
                                      nTracks = (int)j.Jet.nTrk,
                                      lowestPtTrack = trkList.First().pT,
                                  };
            return trainingDataSet;
        }
开发者ID:gordonwatts,项目名称:JetCutStudies,代码行数:53,代码来源:Program.cs

示例8: ProcessSample

        /// <summary>
        /// Make a series of plots for the LLP's.
        /// </summary>
        /// <param name="llp"></param>
        /// <param name="dir"></param>
        private static void ProcessSample(IQueryable<Files.MetaData> llp, FutureTDirectory dir)
        {
            // Dump basic plots with info for the LLPs.
            var llpStream = llp.SelectMany(l => l.Data.LLPs);
            llpStream
                .PlotBasicLLPValues("all", dir);

            // Next, for LLP's with a jet near them.
            var llpStreamWithJets = llp.SelectMany(ev => ev.Data.Jets)
                .Where(j => j.LLP.IsGoodIndex());
            llpStreamWithJets
                .Select(j => j.LLP)
                .PlotBasicLLPValues("withJet", dir);
            var llpStreamWithGoodJets = llpStreamWithJets
                .Where(j => j.ET > 40.0 && Math.Abs(j.eta) < JetEtaLimit);
            llpStreamWithGoodJets
                .Select(j => j.LLP)
                .PlotBasicLLPValues("withGoodJet", dir);
            llpStreamWithGoodJets
                .Where(j => Math.Abs(j.eta) <= 1.7)
                .PlotBasicValues("withGoodJetBarrel", dir);
            llpStreamWithGoodJets
                .Where(j => Math.Abs(j.eta) > 1.7)
                .PlotBasicValues("withGoodJetEndCap", dir);

            // Look at the number of times sharing occurs (should never happen)
            var sharedJets = from ev in llp
                             from j1 in ev.Data.Jets
                             from j2 in ev.Data.Jets
                             where j1.isGoodLLP && j2.isGoodLLP
                             where j1.LLP.IsGoodIndex() && j2.LLP.IsGoodIndex()
                             where j1 != j2
                             where j1.LLP == j2.LLP
                             select Tuple.Create(j1, j2);

            var count = sharedJets.FutureCount();

            FutureWriteLine(() => $"  Number of jets that share an LLP: {count.Value}");

            // Calculate how close things are for the LLP's
            var sharedLLPs = from ev in llp
                             let l1 = ev.Data.LLPs.First()
                             let l2 = ev.Data.LLPs.Skip(1).First()
                             select Tuple.Create(l1, l2);

            sharedLLPs
                .Select(l => Sqrt(DeltaR2(l.Item1.eta, l.Item1.phi, l.Item2.eta, l.Item2.phi)))
                .FuturePlot("DeltaRLLP", "The DeltaR between the two LLPs in the event", 20, 0.0, 3.0)
                .Save(dir);

            sharedLLPs
                .Select(l => DeltaPhi(l.Item1.phi, l.Item2.phi))
                .FuturePlot("DeltaPhiLLP", "The DeltaPhi between the two LLPs in the event", 60, 0.0, PI)
                .Save(dir);

            // How many LLPs are within 0.4 of a jet?
            Expression<Func<recoTreeJets, recoTreeLLPs, double>> DR2 = (l, j) => DeltaR2(l.eta, l.phi, j.eta, j.phi);
#if false
            double openingAngle = 0.4;
            var llpsCloseToJets = from ev in llp
                                  select from j in ev.Data.Jets
                                         where j.isGoodLLP
                                         select from lp in ev.Data.LLPs
                                                let dr = DR2.Invoke(j, lp)
                                                let dphi = Abs(DeltaPhi(j.phi, lp.phi))
                                                select Tuple.Create(j, lp, dr, dphi);

            llpsCloseToJets
                .SelectMany(jets => jets)
                .Select(llps => llps.Where(tup => tup.Item3 < openingAngle * openingAngle).Count())
                .FuturePlot("nLLPsCloseToJet", $"Number of LLPs with DR < {openingAngle}", 5, 0.0, 5.0)
                .Save(dir);

            llpsCloseToJets
                .SelectMany(jets => jets)
                .FuturePlot("maxDRForLLPs", "Max DR between each Jet and all LLPs in event",
                    60, 0.0, 3.0, jets => Sqrt(jets.Max(v => v.Item3)))
                .Save(dir);

            llpsCloseToJets
                .SelectMany(jets => jets)
                .FuturePlot("maxDPhiForLLPs", "Max DPhi between each jet and all LLPs in event",
                    60, 0, PI, jets => jets.Max(v => v.Item4))
                .Save(dir);

            llpsCloseToJets
                .SelectMany(jets => jets)
                .Where(j => j.First().Item1.logRatio > 1.2)
                .FuturePlot("maxDRForLLPsInCRJets", "Max DR between each CR Jet (logR>1.2) and all LLPs in event",
                    60, 0.0, 3.0, jets => Sqrt(jets.Max(v => v.Item3)))
                .Save(dir);

            llpsCloseToJets
                .SelectMany(jets => jets)
                .Where(j => j.First().Item1.logRatio > 1.2)
//.........这里部分代码省略.........
开发者ID:gordonwatts,项目名称:JetCutStudies,代码行数:101,代码来源:Program.cs

示例9: Search

        public IQueryable<Request> Search(IQueryable<Request> requests, string query)
        {
            query = query.ToLower();

            var result = requests.SelectMany(i => i.OriginalRequest.Requests.Where(x => x.ApplicationName.ToLower().Contains(query) ||
                x.BusinessService.ToLower().Contains(query) ||
                x.Notes.ToLower().Contains(query) ||
                x.User.FirstName.ToLower().Contains(query) ||
                x.User.LastName.ToLower().Contains(query) ||
                x.Owner.FirstName.ToLower().Contains(query) ||
                x.Owner.LastName.ToLower().Contains(query) ||
                x.RequestApplicationTypes.Any(y => y.ApplicationType.Name.ToLower().Contains(query)) ||
                x.Virtualization.DNSName.ToLower().Contains(query) ||
                x.Virtualization.NetBIOSName.ToLower().Contains(query) ||
                x.Virtualization.OperatingSystem.Name.ToLower().Contains(query) ||
                x.Virtualization.Server.Location.Name.ToLower().Contains(query) ||
                x.Virtualization.Server.ServerType.Name.ToLower().Contains(query) ||
                x.Virtualization.Server.BladeChassi.RackChassisPort.ToLower().Contains(query) ||
                x.SecurityActions.Any(sa =>
                    sa.Notes.ToLower().Contains(query) ||
                    sa.User.FirstName.ToLower().Contains(query) ||
                    sa.User.LastName.ToLower().Contains(query)) ||
                x.CommunicationActions.Any(ca =>
                    ca.Notes.ToLower().Contains(query) ||
                    ca.User.FirstName.ToLower().Contains(query) ||
                    ca.User.LastName.ToLower().Contains(query))
                ));

            DateTime dateTime;

            if (DateTime.TryParseExact(query, "d/M/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.AllowWhiteSpaces, out dateTime))
            {
                dateTime = dateTime.Date;

                result = result.Union(requests.SelectMany(i =>
                    i.OriginalRequest.Requests.Where(x =>
                        EntityFunctions.TruncateTime(x.SubmissionDate).Value.Equals(dateTime) ||
                        (x.DeleteDate.HasValue && EntityFunctions.TruncateTime(x.DeleteDate).Value.Equals(dateTime)) ||
                        x.RequestPorts.Any(p =>
                            (p.Port.StartDate.HasValue && EntityFunctions.TruncateTime(p.Port.StartDate.Value).Value.Equals(dateTime))  ||
                            (p.Port.EndDate.HasValue && EntityFunctions.TruncateTime(p.Port.EndDate.Value).Value.Equals(dateTime))
                        ) ||
                        x.SecurityActions.Any(sa => EntityFunctions.TruncateTime(sa.Date).Value.Equals(dateTime)) ||
                        x.CommunicationActions.Any(ca => EntityFunctions.TruncateTime(ca.Date).Value.Equals(dateTime))
                    )
                ));
            }

            IPAddress address;

            if (IPAddress.TryParse(query, out address))
            {
                var bytes = address.GetAddressBytes();

                result = result.Union(requests.SelectMany(i =>
                    i.OriginalRequest.Requests.Where(x =>
                        x.CommunicationActions.Any(ca => ca.ServerIP.IP.Address == bytes) ||
                        x.RequestPorts.Any(p => p.Port.IP.Address == bytes)
                    )
                ));
            }

            var reqs = db.Requests.AsQueryable();

            var tmp = result;

            result = result.GroupBy(x => x.OriginalRequest).Select(x => x.Key.Requests.OrderByDescending(o => o.Id).FirstOrDefault());

            //result = result.Where(x => !reqs.Any(y => y.OldRequestId == x.Id));

            return result.OrderByDescending(x => x.SubmissionDate);
        }
开发者ID:osama-lionheart,项目名称:ServerRequests,代码行数:72,代码来源:RequestRepository.cs

示例10: DetermineDeviceMembers

 private IEnumerable<string> DetermineDeviceMembers(IQueryable<User> Users)
 {
     return Users
         .SelectMany(u => u.DeviceUserAssignments)
         .Where(da => !da.UnassignedDate.HasValue && da.Device.DeviceDomainId != null)
         .Select(da => da.Device.DeviceDomainId)
         .ToList()
         .Where(ActiveDirectory.IsValidDomainAccountId)
         .Select(id => id + "$");
 }
开发者ID:garysharp,项目名称:Disco,代码行数:10,代码来源:UserFlagUserDevicesManagedGroup.cs


注:本文中的IQueryable.SelectMany方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。