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


C# IQueryable.Any方法代码示例

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


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

示例1: ExtractMentions

        public static IList<string> ExtractMentions(string message, IQueryable<ChatUserMention> mentions = null)
        {
            if (message == null)
                return new List<string>();

            // Find username mentions
            var matches = Regex.Matches(message, UsernameMentionPattern)
                .Cast<Match>()
                .Where(m => m.Success)
                .Select(m => m.Groups["user"].Value.Trim())
                .Where(u => !String.IsNullOrEmpty(u))
                .ToList();

            // Find custom mentions
            if (mentions == null || !mentions.Any()) return matches;

            var regex = new Regex(GetPattern(mentions), RegexOptions.IgnoreCase);

            foreach (var match in regex.Matches(message)
                                       .Cast<Match>()
                                       .Where(m => m.Success))
            {
                for (var i = 1; i < match.Groups.Count; i++)
                {
                    if (!match.Groups[i].Success) continue;

                    matches.Add(regex.GroupNameFromNumber(i));
                }
            }

            return matches;
        }
开发者ID:Widdershin,项目名称:vox,代码行数:32,代码来源:MentionExtractor.cs

示例2: CreateFilteredRequestTable

        public static MvcHtmlString CreateFilteredRequestTable(this HtmlHelper helper, IQueryable<FilteredRequestRecord> filteredRequestRecords, Localizer T)
        {
            StringBuilder sb = new StringBuilder();

            if (filteredRequestRecords == null || !filteredRequestRecords.Any())
            {
                sb.AppendLine(T("No requests are filtered yet.").Text);
            }
            else
            {
                sb.AppendLine("<table><tr>");
                sb.AppendFormat("<th>{0}</th>", T("Request time"));
                sb.AppendFormat("<th>{0}</th>", T("Url"));
                sb.AppendFormat("<th>{0}</th>", T("User Host Address"));
                sb.AppendFormat("<th>{0}</th>", T("User Agent"));
                sb.AppendLine("</tr>");

                foreach (FilteredRequestRecord filteredRequest in filteredRequestRecords.OrderByDescending(r => r.RequestTime))
                {
                    sb.AppendLine("<tr>");
                    sb.AppendFormat("<td>{0}</td>", filteredRequest.RequestTime);
                    sb.AppendFormat("<td>{0}</td>", filteredRequest.Url);
                    sb.AppendFormat("<td>{0}</td>", filteredRequest.UserHostAddress);
                    sb.AppendFormat("<td>{0}</td>", filteredRequest.UserAgent);
                    sb.AppendLine("</tr>");
                }
                sb.AppendLine("</table>");
            }
            return new MvcHtmlString(sb.ToString());
        }
开发者ID:rijkshuisstijl,项目名称:Rijkshuisstijl.UrlProtector,代码行数:30,代码来源:UrlProtectorHtmlHelper.cs

示例3: InsertContinuousIntoSequence

        /// <summary>
        /// Вставляет изменяемую со временем величину в последовательность, выполняя необходимые преобразования. !!! не вызывает ExecuteDynamicInsert
        /// </summary>
        /// <param name="Inserted">Вставляемая запись</param>
        /// <param name="History">Последовательность изменений данного параметра</param>
        private void InsertContinuousIntoSequence(IContinuous Inserted, IQueryable<IContinuous> History)
        {
            if (Inserted.EndDate != null && History.Any(p => p.StartDate > Inserted.StartDate && p.EndDate < Inserted.EndDate))
                throw new Exception("Добавляемой значение перекрывает уже имеющееся в базе, что нарушает логику построения базы и, скорее всего, свидетельствует об ошибке.");

            var Previus = History
                .Where(p => p.StartDate < Inserted.StartDate)
                .OrderByDescending(p => p.StartDate)
                .FirstOrDefault();

            var Next = History
                .Where(p => p.StartDate > (Inserted.EndDate ?? Inserted.StartDate))
                .OrderBy(p => p.StartDate)
                .FirstOrDefault();

            if (Next != null)
            {
                if (Inserted.EndDate == null) Inserted.EndDate = Next.StartDate;
                else throw new NotImplementedException(String.Format("Указана конечная дата действия свойства, и существует свойство, с датой начала, позже даты конца действия этого свойства. Такой функционал не реализован."));
            }
            if (Previus != null && (Previus.EndDate == null || Previus.EndDate > Inserted.StartDate))
            {
                Previus.EndDate = Inserted.StartDate;
                ExecuteDynamicUpdate(Previus);
            }
        }
开发者ID:NpoSaut,项目名称:LocoBase,代码行数:31,代码来源:LocoDataContext.cs

示例4: ValidateSalaryCalculationPreConditions

 public void ValidateSalaryCalculationPreConditions(DateTime periodStartDate, DateTime periodEndDate,
     IQueryable<SalaryCalculation> previousSalaries)
 {
     if (previousSalaries.Any(salaryCalculation => salaryCalculation.PeriodStartDate == periodStartDate &&
                                                   salaryCalculation.PeriodEndDate == periodEndDate))
     {
         throw new SalaryCalculationException("Salary calculation exists already for this period");
     }
 }
开发者ID:Andrey1de,项目名称:SalaryCalculationApp,代码行数:9,代码来源:SalaryCalculationValidation.cs

示例5: RemoveRecurringCondition

 public bool RemoveRecurringCondition(IQueryable<Recurring> instances)
 {
     if (instances.Any())
     {
         Db.Recurrings.RemoveRange(instances);
         Db.SaveChanges();
         return true;
     }
     return false;
 }
开发者ID:h4k,项目名称:asp-test,代码行数:10,代码来源:Recurring.cs

示例6: ArticleSearchResult

        public ArticleSearchResult(IQueryable<ArticleSearchResultItem> query)
        {
            if (query == null)
            {
                throw new ArgumentNullException("query");
            }

            var suggestionResults = !query.Any() ? query.Suggest() : null;
            var suggestions = (suggestionResults != null) ? suggestionResults.Suggestions : null;

            this.Suggestions = (suggestions ?? Enumerable.Empty<string>()).ToList();

            this.Items = query.ToList();
        }
开发者ID:sebnilsson,项目名称:WikiDown,代码行数:14,代码来源:ArticleSearchResult.cs

示例7: GetPrimaryCustomerAddress

        internal static CustomerAddress GetPrimaryCustomerAddress(IQueryable<CustomerAddress> customerAddresses, AddressType addressType)
        {
            if (!customerAddresses.Any())
            {
                return null;
            }

            CustomerAddress customerBillingAddress = customerAddresses.FirstOrDefault(ca => ca.AddressType == addressType && ca.IsPrimary);
            if (customerBillingAddress == null)
            {
                // There is no primary address. Get the most recent address.
                customerBillingAddress = customerAddresses.Where(ca => ca.AddressType == AddressType.Billing).OrderByDescending(ca => ca.LastModified).First();
            }

            return customerBillingAddress;
        }
开发者ID:vkoppaka,项目名称:Sitefinity-Custom-Checkout,代码行数:16,代码来源:CustomerAddressHelper.cs

示例8: BuildIndex

        public ISpatialIndex BuildIndex(IQueryable<ISpatialDocument> documents)
        {
            if (!documents.Any()) return new EmptySpatialIndex();

            var mercator = new Boundary(new Point(0, 0), 180, 90);
            var quadTree = new QuadTree<SpatialDocument>(mercator);

            foreach (var doc in documents)
            {
                quadTree.Insert(new SpatialDocument(doc));
            }

            var index = new SpatialIndex(quadTree);

            return index;
        }
开发者ID:clapis,项目名称:roamler,代码行数:16,代码来源:SpatialIndexBuilder.cs

示例9: Find_PersonByName

 private static IQueryable<PersonProfile> Find_PersonByName()
 {
     Console.WriteLine("Buscar Perfil: ");
     name = Console.ReadLine();
     nameIQ = from person in db.User_profile where person.FirstName + " " + person.LastName == name select person;
     if (!nameIQ.Any())
     {
         Console.WriteLine("No se encuentra Este perfil No existe");
         ShowUserInfo();
     }
     Console.WriteLine("Este perfil existe");
     return nameIQ;
 }
开发者ID:xryan0512,项目名称:Chocolate-Factory,代码行数:13,代码来源:Controller.cs

示例10: AddOrResendInvitation

        private void AddOrResendInvitation(string inviteeEmail, Invitation i, IQueryable<Invitation> prevSentInvitations)
        {
            if (prevSentInvitations.Any(o => o.StatusValue == (int) InvitationStatus.Blocked))
                throw new Exception("This user blocked invitations from you.");

            //check already existing invitation to this project
            var prevSentToThisProject = prevSentInvitations.FirstOrDefault(o => o.ProjectId == i.ProjectId);
            if (prevSentToThisProject != null)
            {
                switch (prevSentToThisProject.Status)
                {
                    case InvitationStatus.Sent:
                        throw new Exception("You have already sent invitation to this user.");
                        break;
                    case InvitationStatus.Accepted:
                        throw new Exception("This user is already in your team.");
                        break;
                    case InvitationStatus.Declined:
                        prevSentToThisProject.LastSentDate = DateTime.UtcNow;
                        //resend invitation email again
                        MessageService.SendEmail(inviteeEmail, "Invitation to project", "InviteToProject",
                                                 new EmailDTO<Invitation>(prevSentToThisProject));
                        Database.ObjectContext.ApplyCurrentValues("Invitations", prevSentToThisProject);
                        Database.SaveChanges();
                        return;
                        break;
                }
            }
            i.Project = Database.Projects.FirstOrDefault(p => p.Id == i.ProjectId);
            Database.Invitations.Add(i);
            Database.SaveChanges();
            //sent email
            MessageService.SendEmail(inviteeEmail, "Invitation to project", "InviteToProject",
                                     new EmailDTO<Invitation>(i));
        }
开发者ID:Sirix,项目名称:NProject2,代码行数:35,代码来源:UserService.cs

示例11: Filter

 /// <summary>
 /// Extends the where clausle of the given IQueryable List with this condition filter
 /// </summary>
 /// <param name="dataQry"></param>
 /// <returns></returns>
 public override IQueryable<object> Filter(IQueryable<object> dataQry) {
     if (dataQry.Any()) {
         //
         // Cache Property Info if necessary
         //
         if (Property == null) {
             Property =
             dataQry.First().GetType().GetProperty(_propertyName);
             if (_property == null)
                 throw new NotSupportedException(string.Format(
                     "Your objects in the provided List doesn't have the specified public property {0}!", _propertyName));
         }
     }
     return base.Filter(dataQry);
 }
开发者ID:ElderByte-,项目名称:Archimedes.Patterns,代码行数:20,代码来源:DynamicConditionExpression.cs

示例12: ProcessTariffsAsync

        /*/// <summary>
        /// The process tariffs async.
        /// </summary>
        /// <param name="tariffs">
        /// The tariffs.
        /// </param>
        /// <param name="fileName">
        /// The file name.
        /// </param>
        /// <param name="tariffAction">
        /// The tariff Action.
        /// </param>
        private static async Task ProcessTariffsAsync(
            IQueryable<Tariff> tariffs, 
            string fileName, 
            TariffAction tariffAction)
        {
            Process(tariffs, fileName, tariffAction)
          // await Task.Run(() => Process(tariffs, fileName, tariffAction));
        }*/

        /// <summary>
        /// Processes the specified tariffs.
        /// </summary>
        /// <param name="tariffs">
        /// The tariffs.
        /// </param>
        /// <param name="fileName">
        /// Name of the file.
        /// </param>
        /// <param name="tariffAction">
        /// The tariff action.
        /// </param>
        /// <param name="dataAccessHelper">
        /// The data access helper.
        /// </param>
        /// <param name="startYearAndMonth">
        /// The start year and month.
        /// </param>
        private static void Process(
            IQueryable<Tariff> tariffs, 
            string fileName, 
            TariffAction tariffAction, 
            TariffsDataAccessHelper dataAccessHelper, 
            string startYearAndMonth)
        {
            if (!tariffs.Any())
            {
                return;
            }

            if (string.IsNullOrEmpty(fileName))
            {
                return;
            }

            switch (tariffAction)
            {
                case TariffAction.Compare:
                    CompareTariffs(fileName, tariffs, dataAccessHelper, startYearAndMonth);
                    break;
                case TariffAction.GenerateScript:
                    CreateTariffScript(fileName, tariffs, startYearAndMonth);
                    break;
            }
        }
开发者ID:benitazz,项目名称:UmehlukoTools,代码行数:66,代码来源:TariffProcessorHelper.cs

示例13: SaveBadges

 public static void SaveBadges(IQueryable<BadgeAwardDTO> badges)
 {
     if (badges != null && badges.Any())
     {
         var dal = IoC.Container.Resolve<IAwardBadgesDAL>();
         dal.SaveEarnedBadges(badges);
     }
 }
开发者ID:jpeterson7755,项目名称:Badge-Application,代码行数:8,代码来源:AwardBadges.cs

示例14: ChangeValue

        private static void ChangeValue(TypedAttribute nodeNameAttr, IQueryable<TypedEntity> parentQuery, TypedEntity item, string potentialValue, string valueKey, string existsSuffixCheck, string defaultSuffix, string dupeFormat)
        {
            var iterationCount = 0;
            var itExists = false;
            var originalValue = potentialValue;
            var valueCheck = potentialValue;
            do
            {
                iterationCount++;
                itExists = parentQuery.Any(x => x.InnerAttribute<string>(NodeNameAttributeDefinition.AliasValue, valueKey) == valueCheck && x.Id != item.Id);
                if (itExists)
                {
                    // Don't concatenate (1) (2) etc. just use the original value plus a count
                    valueCheck = originalValue + string.Format(dupeFormat, iterationCount);
                }
            } while (itExists);

            if (iterationCount > 1)
            {
                nodeNameAttr.Values[valueKey] = valueCheck;
            }

            //var exists = parentQuery
            //    .Any(x => x.InnerAttribute<string>(NodeNameAttributeDefinition.AliasValue, valueKey) == potentialValue && x.Id != item.Id);

            //if (exists)
            //{
            //    // Get the count of items matching potentialValue + "("
            //    var dupeName = potentialValue + existsSuffixCheck;
            //    var items = parentQuery
            //        .Where(
            //            x =>
            //            x.InnerAttribute<string>(NodeNameAttributeDefinition.AliasValue, valueKey).StartsWith(dupeName) &&
            //            x.Id != item.Id)
            //        .ToList();

            //    var itemsDebug = items.Select(x => new
            //        {
            //            x.Id,
            //            x.Attributes,
            //            ValueKey = x.InnerAttribute<string>(NodeNameAttributeDefinition.AliasValue, valueKey)
            //        }).ToArray();

            //    var count = items.Count;

            //    if (count == 0)
            //    {
            //        potentialValue = potentialValue + defaultSuffix;
            //    }
            //    else
            //    {
            //        var newCount = (count + 1);
            //        var format = string.Format(dupeFormat, newCount);
            //        potentialValue = potentialValue + format;
            //    }
            //}

            //nodeNameAttr.Values[valueKey] = potentialValue;
        }
开发者ID:paulsuart,项目名称:rebelcmsxu5,代码行数:59,代码来源:EnsureUniqueNameTask.cs

示例15: ValidateCommentAsUsersUnhappy

 public string ValidateCommentAsUsersUnhappy(IQueryable<SalesOrderHeader> toOrders) {
     return toOrders.Any(o => !o.IsShipped()) ? "Not all shipped yet" : null;
 }
开发者ID:Robin--,项目名称:NakedObjectsFramework,代码行数:3,代码来源:OrderContributedActions.cs


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