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


C# IQueryable.ForEach方法代码示例

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


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

示例1: LoadQuestion

        private void LoadQuestion(int questionid)
        {
            IsQLSave = true; IsSaved = true;

            #region Load Questions
            DataTable dt = gridControlQuestions.DataSource as DataTable;
            m_oQuestion = BPContext.questions.Include("questions_text_language").FirstOrDefault(p => p.id == questionid);
            if (m_oQuestion == null) {
                return;
            }
            btnEditQuestion.Enabled = true;
            btnDeleteQuestion.Enabled = true;

            if (m_oQuestion.general_value != null && !string.IsNullOrEmpty(m_oQuestion.general_value.ToString()))
                comboBoxEditQuestionGeneralValue.EditValue = m_oQuestion.general_value.ToString();
            var qtl = m_oQuestion.questions_text_language.Where(p => p.MGC == false);

            DataRow dr = null;
            qtl.ForEach(delegate(questions_text_language dqtl) {
                dr = dt.NewRow();
                dr["question_id"] = dqtl.questions_id;
                dr["question_text_language_id"] = dqtl.id;
                dr["language_id"] = dqtl.language_id;
                dr["question"] = dqtl.question_text;
                dr["description"] = dqtl.question_description;
                dr["helptext"] = dqtl.question_help_text;
                dt.Rows.Add(dr);
            });
            dt.AcceptChanges();

            dictionarySelectedTags = new Dictionary<string, int>();
            var qqt = m_oQuestion.questions_questiontags;
            questiontag qt = null;
            KeyValuePair<string, int> ItemToAdd = new KeyValuePair<string, int>(); //[@jeff 09.15.2011 #462]: added
            qqt.ForEach(delegate(questions_questiontags dqts) {
                qt = dqts.questiontag;
                //[@jeff 09.15.2011 #462]: check key val pair if exists in the dictionary, before insert
                ItemToAdd = new KeyValuePair<string, int>(qt.title, qt.id);
                if (!dictionarySelectedTags.ContainsKey(qt.title))
                    dictionarySelectedTags.Add(qt.title, qt.id);
            });

            simpleButtonSaveQuestion.Enabled = true;
            groupControlAnswerForm.Enabled = true;
            #endregion

            #region Load Answer forms
            dt = gridControlAnswerForm.DataSource as DataTable;
            m_oQuestionLayouts = BPContext.questionlayouts.Include("questionlayout_language").Where(p => p.questions_id == questionid);
            if (m_oQuestionLayouts != null && m_oQuestionLayouts.Count() > 0) {
                btnEditAnswerform.Enabled = true;
                btnDeleteAnswerform.Enabled = true;
            } else {
                btnEditAnswerform.Enabled = false;
                btnDeleteAnswerform.Enabled = false;
            }
            CampaignQuestionnaire cQ = null;
            var cbeItems = comboBoxEditComponentType.Properties.Items;
            string componentType = string.Empty;
            questionlayout_language qlang = null;
            m_oQuestionLayouts.ForEach(delegate(questionlayout ql) {
                cQ = CampaignQuestionnaire.InstanciateWith(ql.content_json);
                for (int x = 0; x < cbeItems.Count; ++x) {
                    if (cbeItems[x].ToString().ToLower() == cQ.Type.ToLower())
                        componentType = cbeItems[x].ToString();
                }
                dr = dt.NewRow();
                dr["question_id"] = ql.questions_id;
                dr["question_layout_id"] = ql.id;
                dr["title"] = ql.title;
                dr["component_type"] = componentType;
                dr["general_value"] = ql.general_value;
                dr["account_level"] = ql.account_level;
                dr["properties"] = cQ;
                qlang = ql.questionlayout_language.FirstOrDefault();
                if (qlang != null) {
                    dr["language"] = qlang.language.name;
                    dr["language_id"] = qlang.language_id;
                } else {
                    dr["language"] = null;
                    dr["language_id"] = null;
                }
                dt.Rows.Add(dr);
            });
            dt.AcceptChanges();
            if (dt.Rows.Count <= 0) {
                btnEditAnswerform.Enabled = false;
                btnDeleteAnswerform.Enabled = false;
            }
            #endregion
        }
开发者ID:,项目名称:,代码行数:91,代码来源:


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