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


C# List.SingleOrDefault方法代码示例

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


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

示例1: BindComboBox

        void BindComboBox()
        {
            List<IModelObject> m_objList = codeMasterBL.SearchRecords(new CodeMaster_cmt_Info()
            {
                cmt_cKey1 = DefineConstantValue.CodeMasterDefine.KEY1_TYPEVALUE,
                cmt_cKey2 = DefineConstantValue.CodeMasterDefine.KEY2_MATERIALTYPE
            });

            if (m_objList != null)
            {
                _TypeList = new List<CodeMaster_cmt_Info>();
                // _TypeList.Add(new CodeMaster_cmt_Info() { cmt_cValue = "", cmt_cRemark = "" });
                List<ComboBoxItem> cbis = new List<ComboBoxItem>();
                ComboBoxItem cbi = new ComboBoxItem("", "");
                cbis.Add(cbi);
                foreach (IModelObject item in m_objList)
                {
                    _TypeList.Add(item as CodeMaster_cmt_Info);
                    var nitem = item as CodeMaster_cmt_Info;
                    if (cbis.SingleOrDefault(d => d.Value.ToString() == nitem.cmt_cValue) == null)
                    {
                        cbis.Add(new ComboBoxItem(nitem.cmt_cRemark, nitem.cmt_cValue));
                    }
                }
                // cbType.ValueMember = "cmt_cValue";
                //  cbType.DisplayMember = "cmt_cRemark";
                // cbType.DataSource = _TypeList;
                cbType.DataSource = cbis;
            }

            m_objList = _MaterialMasterBll.SearchRecords_SQL(new MaterialProfile_mlpf_Info());

            if (m_objList != null)
            {
                _BrandList = new List<MaterialProfile_mlpf_Info>();
                _BrandList.Add(new MaterialProfile_mlpf_Info() { mlpf_cMaterialBrand = "" });
                List<ComboBoxItem> cbis = new List<ComboBoxItem>();
                ComboBoxItem cbi = new ComboBoxItem("", "");
                cbis.Add(cbi);
                foreach (IModelObject item in m_objList)
                {

                    var nitem = item as MaterialProfile_mlpf_Info;
                    _BrandList.Add(nitem);
                    if (cbis.SingleOrDefault(d => d.Text == nitem.mlpf_cMaterialBrand) == null)
                    {
                        cbis.Add(new ComboBoxItem(nitem.mlpf_cMaterialBrand, nitem.mlpf_cMaterialBrand));
                    }
                }
                //cbBrand.ValueMember = "mlpf_cMaterialBrand";
                // cbBrand.DisplayMember = "mlpf_cMaterialBrand";
                // cbBrand.DataSource = _BrandList;
                cbBrand.DataSource = cbis;
            }

            m_objList = codeMasterBL.SearchRecords(new CodeMaster_cmt_Info()
            {
                cmt_cKey1 = DefineConstantValue.CodeMasterDefine.KEY1_TYPEVALUE,
                cmt_cKey2 = DefineConstantValue.CodeMasterDefine.KEY2_MATERIALUNIT
            });
            if (m_objList != null)
            {
                _UnitList = new List<CodeMaster_cmt_Info>();
                foreach (IModelObject item in m_objList)
                {
                    _UnitList.Add(item as CodeMaster_cmt_Info);
                }
            }
        }
开发者ID:Klutzdon,项目名称:PBIMSN,代码行数:69,代码来源:frmMaterialMaster.cs


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