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


C# IQueryable.First方法代码示例

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


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

示例1: SiteModel

        public SiteModel(SiteContext context, string contentId, string productId, bool notFound = false)
        {
            Contents = context.Contents;
            Title = "Студия Евгения Миллера";
            var minSortorder = Contents.Min(c => c.SortOrder);
            foreach (var content in Contents.Where(content => content.SortOrder == minSortorder))
            {
                content.IsHomepage = true;
                break;
            }

            if (productId != null)
            {
                Product = context.Products.FirstOrDefault(p => p.Name == productId);
                if (Product == null)
                {
                    throw new HttpException(404, "page not found");
                }
                Content = Product.Content;
            }
            else if (contentId == "")
            {
                //Content = Contents.First(c => c.IsHomepage==true);
                Content = Contents.First(content => content.SortOrder == minSortorder);
            }
            else
            {
                Content = Contents.FirstOrDefault(c => c.Name == contentId);
            }

            if (Content == null)
            {
                throw new HttpException(404, "page not found");
            }

            var contentName = Content.Name;

            Menu = new List<Helpers.MenuItem>();

            foreach (var c in Contents)
            {
                Menu.Add(new Helpers.MenuItem
                {
                    ContentId = c.Id,
                    ContentName = c.Name,
                    Current = !notFound && ((c.Name == contentId || contentId == "" && c.IsHomepage) && Product == null),
                    Selected = !notFound && c.Name == contentName,
                    SortOrder = c.SortOrder,
                    Title = c.Title
                });
            }

            Title += " » " + Content.Title;

            SeoDescription = Content.SeoDescription;
            SeoKeywords = Content.SeoKeywords;

        }
开发者ID:fathurxzz,项目名称:aleqx,代码行数:58,代码来源:SiteModel.cs

示例2: SiteModel

        public SiteModel(SiteContext context, string contentId, int? productId = null)
        {
            Contents = context.Content;
            Title = "Майкаджексон";
            var minSortorder = Contents.Min(c => c.SortOrder);
            foreach (var content in Contents.Where(content => content.SortOrder == minSortorder))
            {
                content.IsHomepage = true;
                break;
            }

            // в случае заходи на страницу продукта
            if (contentId == null)
            {
                Product = context.Product.First(p => p.Id == productId);
                Content = Product.Content;
            }
            else if (contentId == "")
            {
                //Content = Contents.First(c => c.IsHomepage==true);
                Content = Contents.First(content => content.SortOrder == minSortorder);
            }
            else
            {
                Content = Contents.FirstOrDefault(c => c.Name == contentId);
            }



            Menu = new List<Helpers.MenuItem>();

            foreach (var c in Contents)
            {
                Menu.Add(new Helpers.MenuItem
                {
                    ContentId = c.Id,
                    ContentName = c.Name,
                    Current = c.Name == contentId || contentId == "" && c.IsHomepage,
                    Selected = c.Name == Content.Name,
                    SortOrder = c.SortOrder,
                    Title = c.MenuTitle,
                    ContentType = (ContentType)c.ContentType
                });
            }

            SeoDescription = Content.SeoDescription;
            SeoKeywords = Content.SeoKeywords;
        }
开发者ID:fathurxzz,项目名称:aleqx,代码行数:48,代码来源:SiteModel.cs

示例3: PDFTable

        private static void PDFTable(StringBuilder sb, IQueryable<SellsReport> reports)
        {
            var date = reports.First().FromDate;
            sb.Append("<table border=\"1\">");
            sb.AppendFormat("<tr bgcolor='#D3D3D3'><td colspan=\"5\">Date: {0}</td></tr>", date.ToString("yyyy-MM-dd"));
            AppendNewTableHeader(sb);
            decimal totalSum = 0;
            decimal grantTotal = 0;
            foreach (var report in reports)
            {

                if (date != report.FromDate)
                {
                    sb.Append("<tr><td colspan=\"4\" align=\"right\">Total sum for " + report.FromDate.ToString("yyyy-MM-dd") + ":</td><td style='font-weight:bold'>" + totalSum + "</td></tr>");
                    //sb.Append("</table>");
                    sb.AppendFormat("<tr bgcolor='#D3D3D3'><td colspan=\"5\">Date: {0}</td></tr>", report.FromDate.ToString("yyyy-MM-dd"));
                    date = report.FromDate;
                    AppendNewTableHeader(sb);
                    grantTotal += totalSum;
                    totalSum = 0;
                }
                decimal sum = report.Quantity * report.UnitPrice;
                sb.Append("<tr>");
                sb.AppendFormat("<td>{0}</td>", report.Product.Product_Name);
                sb.AppendFormat("<td>{0}</td>", report.Quantity);
                sb.AppendFormat("<td>{0}</td>", report.UnitPrice);
                sb.AppendFormat("<td>{0}</td>", report.Location);
                sb.AppendFormat("<td>{0}</td>", sum);
                totalSum += sum;
                sb.Append("</tr>");
            }
            sb.Append("<tr><td colspan=\"4\" align=\"right\">Total sum for " + date.ToString("yyyy-MM-dd") + ":</td><td style='font-weight:bold'>" + totalSum + "</td></tr>");
            //sb.Append("</table>");
            grantTotal += totalSum;
            sb.Append("<tr><td colspan=\"4\" align=\"right\">Grand Total :</td><td style='font-weight:bold'>" + grantTotal + "</td></tr>");
            sb.Append("</table>");
            
        }
开发者ID:Jarolim,项目名称:AllMyHomeworkForTelerikAcademy,代码行数:38,代码来源:Program.cs

示例4: Execute

        protected virtual object Execute(IQueryable<TextContent> queryable, IEnumerable<OrderExpression> orders, CallType callType, int? skip, int? take)
        {
            #region Order query
            IOrderedQueryable<TextContent> ordered = null;
            foreach (var orderItem in orders)
            {
                if (!orderItem.Descending)
                {
                    if (ordered == null)
                    {
                        ordered = queryable.OrderBy(orderItem.OrderExprssion);
                    }
                    else
                    {
                        ordered = ordered.ThenBy(orderItem.OrderExprssion);
                    }

                }
                else
                {
                    if (ordered == null)
                    {
                        ordered = queryable.OrderByDescending(orderItem.OrderExprssion);
                    }
                    else
                    {
                        ordered = ordered.ThenByDescending(orderItem.OrderExprssion);
                    }
                }
            }
            if (ordered != null)
            {
                queryable = ordered;
            }

            #endregion

            if (skip.HasValue)
            {
                queryable = queryable.Skip(skip.Value);
            }

            if (take.HasValue)
            {
                queryable = queryable.Take(take.Value);
            }
            switch (callType)
            {
                case Kooboo.CMS.Content.Query.Expressions.CallType.Count:
                    return queryable.Count();
                case Kooboo.CMS.Content.Query.Expressions.CallType.First:
                    return queryable.First();
                case Kooboo.CMS.Content.Query.Expressions.CallType.Last:
                    return queryable.Last();
                case Kooboo.CMS.Content.Query.Expressions.CallType.LastOrDefault:
                    return queryable.LastOrDefault();
                case Kooboo.CMS.Content.Query.Expressions.CallType.FirstOrDefault:
                    return queryable.FirstOrDefault();
                case Kooboo.CMS.Content.Query.Expressions.CallType.Unspecified:
                default:
                    return queryable.ToArray();
            }
        }
开发者ID:Epitomy,项目名称:CMS,代码行数:63,代码来源:QueryExecutor.cs

示例5: ValidateExcelForFields

 private void ValidateExcelForFields(ref CampaignValidation validations, List<string> fields, IQueryable<Row> excelRows)
 {
     foreach (var field in fields)
     {
         try
         {
             var chkField = excelRows.First()[field];
         }
         catch (Exception ex)
         {
             validations.Messages.Add(new CampaignValidationMessage(field, CampaignError.FieldMissing, 0));
             validations.IsValid = false;
         }
     }
 }
开发者ID:jojyalexep,项目名称:FireRain,代码行数:15,代码来源:CampaignModule.cs

示例6: 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

示例7: TestQuestionnaireService


//.........这里部分代码省略.........
                    Answers = answers.Where(a => a.AnswerID.Equals(2)).ToList()
                },

                // The current question model breaks down in this situation
                new Question
                {
                    QuestionID = 3,
                    Type = QuestionType.Essay,
                    QuestionText = "Tell me about yourself",
                    MinCorrect = 0,
                    Answers = answers.Where(a => a.AnswerID.Equals(3)).ToList()
                },

                // This situation is why they need a navproperty back up to questions In non-memory
                // based models something like the following would be beneficial a =>
                // a.QuestionID.equals(4) would be a nice expression to utilize

                new Question
                {
                    QuestionID = 4,
                    Type = QuestionType.MultipleAnswer,
                    QuestionText = "Which of these answers are definit?",
                    Answers =
                        answers.Where(a => a.AnswerID.Equals(4) || a.AnswerID.Equals(5) || a.AnswerID.Equals(6))
                            .ToList()
                }
            }.AsQueryable();

            questionnaires = new List<Questionnaire>
            {
                new Questionnaire
                {
                    QuestionnaireID = 1,
                    QuestionnaireTitle = "First Questionnaire",
                    Questions = questions.ToList()
                },
                new Questionnaire
                {
                    QuestionnaireID = 1000,
                    QuestionnaireTitle = "Testing Questionnaire",
                    Questions = questions.ToList()
                }
            }.AsQueryable();

            phoneQuestions = new List<PhoneQuestion>
            {
                new PhoneQuestion
                {
                    QuestionText = "Tell me about your last position",
                    PhoneQuestionnaireID = 1,
                    PhoneQuestionID = 1
                },
                new PhoneQuestion
                {
                    QuestionText = "Tell me about a conflict that you had in your past position and how you resolved it",
                    PhoneQuestionID = 2,
                    PhoneQuestionnaireID = 1
                }
            }.AsQueryable();

            // Create Phone Questionnaire
            phoneQuestionnaires =
                new List<PhoneQuestionnaire>
                {
                    new PhoneQuestionnaire
                    {
开发者ID:Zanion,项目名称:Hire-Me,代码行数:67,代码来源:TestQuestionnaireService.cs

示例8: DeleteMetadata

 private static void DeleteMetadata(MetadataContext context, DeleteResult result, MappingToolDatabaseDataContext mappingDb, IQueryable<Metadata> deleteMetadatas)
 {
     if (deleteMetadatas.Count() == 1)
     {
         Metadata metadata = deleteMetadatas.First();
         if (metadata != null)
         {
             mappingDb.Metadatas.DeleteOnSubmit(metadata);
             try
             {
                 mappingDb.SubmitChanges();
                 result.DeleteSuccessful = true;
                 result.DeletedId = metadata.MetadataId;
                 LoggingService.WriteTrace(LoggingService.Categories.WcfServices, TraceSeverity.Verbose,
                     "Deleted metadata with ID: {0} the value was: '{1}'", metadata.MetadataId.ToString(),
                     metadata.MetadataValue);
             }
             catch (Exception e)
             {
                 LoggingService.WriteTrace(LoggingService.Categories.WcfServices, TraceSeverity.Unexpected,
                     "There was an error deleting the metadata with ID: {0} due to {1}: {2}",
                     metadata.MetadataId.ToString(), e.GetType().ToString(), e.Message);
             }
         }
     }
     else
     {
         LoggingService.WriteTrace(LoggingService.Categories.WcfServices, TraceSeverity.Unexpected,
             "There was an error deleting the metadata with the name {0} from the NodeUid: {1}",
             context.MetadataName, context.NodeUid);
     }
 }
开发者ID:chris-tomich,项目名称:Glyma,代码行数:32,代码来源:MappingToolService.svc.cs

示例9: getFirst

 private Asset getFirst(IQueryable<Asset> assets)
 {
     try
     {
         return assets.First();
     }
     catch
     {
         throw new Exception("Asset Not Found!");
     }
 }
开发者ID:hessamb,项目名称:Divan,代码行数:11,代码来源:AssetList.cs

示例10: GetCsvHeader

        /// <summary>
        /// 
        /// </summary>
        /// <param name="queryable"></param>
        /// <returns></returns>
        private string GetCsvHeader(IQueryable<object> queryable)
        {
            PropertyInfo[] pinfo = GetObjectProperties(queryable.First());
            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < pinfo.Length; i++)
            {
                sb.Append("\"");//enclose every value in quotes
                sb.Append(pinfo[i].Name);
                sb.Append("\"");
                if (i < pinfo.Length - 1)
                {
                    sb.Append(",");
                }
            }
            return sb.ToString();
        }
开发者ID:wizardbyte,项目名称:SimpleCsv,代码行数:22,代码来源:CsvGenerator.cs

示例11: Setup

 public void Setup()
 {
     people = new People();
     generator = new CsvGenerator();
     source = people.QueryThePeople;
     personPropertyCount = GetPropertiesCount(source.First());
 }
开发者ID:wizardbyte,项目名称:SimpleCsv,代码行数:7,代码来源:When_generating_a_csv.cs

示例12: executeQueryMDMOD

 public static String executeQueryMDMOD(IQueryable<String> query)
 {
     return (String)query.First<String>();
 }
开发者ID:duneding,项目名称:CDM-PocEngine,代码行数:4,代码来源:ScenariosTests.cs

示例13: btnPesquisarAluno_Click

 private void btnPesquisarAluno_Click(object sender, EventArgs e)
 {
     if (rdbProntuarioAluno.Checked == true)
     {
         if (String.IsNullOrWhiteSpace(txtPesquisarAluno.Text))
         {
             mensagem("Insira valor no campo de pesquisa!");
         }
         else
         {
             try
             {
                 aluno = getAlunoProntuario(txtPesquisarAluno.Text);
                 if (aluno == null)
                 {
                     mensagem("Falha ao pesquisar aluno");
                 }
                 else
                 {
                     preencherDadosAluno(aluno);
                     gerarSolicitacoes2();
                 }
             }
             catch (Exception ex)
             {
                 mensagem("Falha ao pesquisar aluno. Detalhes: " + ex);
             }
         }
     }
     else if (rdbNomeAluno.Checked == true)
     {
         if (String.IsNullOrWhiteSpace(txtPesquisarAluno.Text))
         {
             mensagem("Insira valor no campo de pesquisa!");
         }
         else
         {
             try
             {
                 var aDAO = new AlunoDAO();
                 alunos = aDAO.get(a => a.nome.StartsWith(txtPesquisarAluno.Text, StringComparison.CurrentCultureIgnoreCase));
                 if (alunos.Count() == 0)
                 {
                     mensagem("Nenhum aluno encontrado");
                     gerarSolicitacoes1();
                 }
                 else if (alunos.Count() == 1)
                 {
                     aluno = alunos.First();
                     preencherDadosAluno(alunos.First());
                     gerarSolicitacoes2();
                 }
                 else
                 {
                     frmAlunos f = new frmAlunos(alunos);
                     f.ShowDialog();
                 }
             }
             catch (Exception ex)
             {
                 mensagem("Nenhum aluno encontrado. Detalhes: " + ex);
                 gerarSolicitacoes1();
             }
         }
     }
 }
开发者ID:Bia0001,项目名称:T,代码行数:66,代码来源:frmPrincipal.cs


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