首页 > 代码库 > 类 映射 遍历大全

类 映射 遍历大全

                foreach (T_GL_AnalysisCalculation item in AnalysisCalculationList)
                {
                    foreach (System.Reflection.PropertyInfo p in item.GetType().GetProperties())
                    {
                        var Key = p.Name;
                        var Value = http://www.mamicode.com/p.GetValue(item, null);


                        #region 行业最优
                        if (Key == "Reporttype" && Value.ToString() == "Max")
                        {
                            foreach (System.Reflection.PropertyInfo pYear in item.GetType().GetProperties())
                            {
                                var KeyYear = pYear.Name;
                                var ValueYear = pYear.GetValue(item, null);
                                if (KeyYear == "Year" && ValueYear.ToString() == "1")
                                {
                                    foreach (System.Reflection.PropertyInfo pYearValue in item.GetType().GetProperties())
                                    {
                                        var KeyYearName = pYearValue.Name;
                                        var KeyYearValue = http://www.mamicode.com/pYearValue.GetValue(item, null);
                                        if (KeyYearName.Length > 5 && KeyYearName.Substring(Key.Length - 5).Replace("_", ".") == code.ToString())
                                        {
                                            entiey.ValueMax1 = Convert.ToDecimal(KeyYearValue);
                                        }
                                    }
                                }
                                if (KeyYear == "Year" && ValueYear.ToString() == "3")
                                {
                                    foreach (System.Reflection.PropertyInfo pYearValue in item.GetType().GetProperties())
                                    {
                                        var KeyYearName = pYearValue.Name;
                                        var KeyYearValue = http://www.mamicode.com/pYearValue.GetValue(item, null);
                                        if (KeyYearName.Length > 5 && KeyYearName.Substring(Key.Length - 5).Replace("_", ".") == code.ToString())
                                        {
                                            entiey.ValueMax3 = Convert.ToDecimal(KeyYearValue);
                                        }
                                    }
                                }
                                if (KeyYear == "Year" && ValueYear.ToString() == "5")
                                {
                                    foreach (System.Reflection.PropertyInfo pYearValue in item.GetType().GetProperties())
                                    {
                                        var KeyYearName = pYearValue.Name;
                                        var KeyYearValue = http://www.mamicode.com/pYearValue.GetValue(item, null);
                                        if (KeyYearName.Length > 5 && KeyYearName.Substring(Key.Length - 5).Replace("_", ".") == code.ToString())
                                        {
                                            entiey.ValueMax5 = Convert.ToDecimal(KeyYearValue);
                                        }
                                    }
                                }
                                if (KeyYear == "Year" && ValueYear.ToString() == "10")
                                {
                                    foreach (System.Reflection.PropertyInfo pYearValue in item.GetType().GetProperties())
                                    {
                                        var KeyYearName = pYearValue.Name;
                                        var KeyYearValue = http://www.mamicode.com/pYearValue.GetValue(item, null);
                                        if (KeyYearName.Length > 5 && KeyYearName.Substring(Key.Length - 5).Replace("_", ".") == code.ToString())
                                        {
                                            entiey.ValueMax10 = Convert.ToDecimal(KeyYearValue);
                                        }
                                    }
                                }
                            }
                        }

                        #endregion

                        #region 行业平均
                        if (Key == "Reporttype" && Value.ToString() == "Average")
                        {
                            foreach (System.Reflection.PropertyInfo pYear in item.GetType().GetProperties())
                            {
                                var KeyYear = pYear.Name;
                                var ValueYear = pYear.GetValue(item, null);
                                if (KeyYear == "Year" && ValueYear.ToString() == "1")
                                {
                                    foreach (System.Reflection.PropertyInfo pYearValue in item.GetType().GetProperties())
                                    {
                                        var KeyYearName = pYearValue.Name;
                                        var KeyYearValue = http://www.mamicode.com/pYearValue.GetValue(item, null);
                                        if (KeyYearName.Length > 5 && KeyYearName.Substring(Key.Length - 5).Replace("_", ".") == code.ToString())
                                        {
                                            entiey.ValueAverage1 = Convert.ToDecimal(KeyYearValue);
                                        }
                                    }
                                }
                                if (KeyYear == "Year" && ValueYear.ToString() == "3")
                                {
                                    foreach (System.Reflection.PropertyInfo pYearValue in item.GetType().GetProperties())
                                    {
                                        var KeyYearName = pYearValue.Name;
                                        var KeyYearValue = http://www.mamicode.com/pYearValue.GetValue(item, null);
                                        if (KeyYearName.Length > 5 && KeyYearName.Substring(Key.Length - 5).Replace("_", ".") == code.ToString())
                                        {
                                            entiey.ValueAverage3 = Convert.ToDecimal(KeyYearValue);
                                        }
                                    }
                                }
                                if (KeyYear == "Year" && ValueYear.ToString() == "5")
                                {
                                    foreach (System.Reflection.PropertyInfo pYearValue in item.GetType().GetProperties())
                                    {
                                        var KeyYearName = pYearValue.Name;
                                        var KeyYearValue = http://www.mamicode.com/pYearValue.GetValue(item, null);
                                        if (KeyYearName.Length > 5 && KeyYearName.Substring(Key.Length - 5).Replace("_", ".") == code.ToString())
                                        {
                                            entiey.ValueAverage5 = Convert.ToDecimal(KeyYearValue);
                                        }
                                    }
                                }
                                if (KeyYear == "Year" && ValueYear.ToString() == "10")
                                {
                                    foreach (System.Reflection.PropertyInfo pYearValue in item.GetType().GetProperties())
                                    {
                                        var KeyYearName = pYearValue.Name;
                                        var KeyYearValue = http://www.mamicode.com/pYearValue.GetValue(item, null);
                                        if (KeyYearName.Length > 5 && KeyYearName.Substring(Key.Length - 5).Replace("_", ".") == code.ToString())
                                        {
                                            entiey.ValueAverage10 = Convert.ToDecimal(KeyYearValue);
                                        }
                                    }
                                }
                            }
                        }


                        #endregion

                        #region 行业最差
                        if (Key == "Reporttype" && Value.ToString() == "Min")
                        {
                            foreach (System.Reflection.PropertyInfo pYear in item.GetType().GetProperties())
                            {
                                var KeyYear = pYear.Name;
                                var ValueYear = pYear.GetValue(item, null);
                                if (KeyYear == "Year" && ValueYear.ToString() == "1")
                                {
                                    foreach (System.Reflection.PropertyInfo pYearValue in item.GetType().GetProperties())
                                    {
                                        var KeyYearName = pYearValue.Name;
                                        var KeyYearValue = http://www.mamicode.com/pYearValue.GetValue(item, null);
                                        if (KeyYearName.Length > 5 && KeyYearName.Substring(Key.Length - 5).Replace("_", ".") == code.ToString())
                                        {
                                            entiey.ValueMin1 = Convert.ToDecimal(KeyYearValue);
                                        }
                                    }
                                }
                                if (KeyYear == "Year" && ValueYear.ToString() == "3")
                                {
                                    foreach (System.Reflection.PropertyInfo pYearValue in item.GetType().GetProperties())
                                    {
                                        var KeyYearName = pYearValue.Name;
                                        var KeyYearValue = http://www.mamicode.com/pYearValue.GetValue(item, null);
                                        if (KeyYearName.Length > 5 && KeyYearName.Substring(Key.Length - 5).Replace("_", ".") == code.ToString())
                                        {
                                            entiey.ValueMin3 = Convert.ToDecimal(KeyYearValue);
                                        }
                                    }
                                }
                                if (KeyYear == "Year" && ValueYear.ToString() == "5")
                                {
                                    foreach (System.Reflection.PropertyInfo pYearValue in item.GetType().GetProperties())
                                    {
                                        var KeyYearName = pYearValue.Name;
                                        var KeyYearValue = http://www.mamicode.com/pYearValue.GetValue(item, null);
                                        if (KeyYearName.Length > 5 && KeyYearName.Substring(Key.Length - 5).Replace("_", ".") == code.ToString())
                                        {
                                            entiey.ValueMin5 = Convert.ToDecimal(KeyYearValue);
                                        }
                                    }
                                }
                                if (KeyYear == "Year" && ValueYear.ToString() == "10")
                                {
                                    foreach (System.Reflection.PropertyInfo pYearValue in item.GetType().GetProperties())
                                    {
                                        var KeyYearName = pYearValue.Name;
                                        var KeyYearValue = http://www.mamicode.com/pYearValue.GetValue(item, null);
                                        if (KeyYearName.Length > 5 && KeyYearName.Substring(Key.Length - 5).Replace("_", ".") == code.ToString())
                                        {
                                            entiey.ValueMin10 = Convert.ToDecimal(KeyYearValue);
                                        }
                                    }
                                }
                            }
                        }


                        #endregion

                    }
                }

 

 

 


                foreach (System.Reflection.PropertyInfo p in entiey.GetType().GetProperties())
                {
                    var Key = p.Name;
                    var Value = http://www.mamicode.com/p.GetValue(entiey, null);
                    if (Key.Substring(0, 1) == "Q")
                    {


                        foreach (var item in AnalysisCalculationQAllList)
                        {
                            if (item.Reporttype == quarter + Key.Substring(1, Key.Length - 1))
                            {
                                foreach (System.Reflection.PropertyInfo I in item.GetType().GetProperties())
                                {
                                    var itemKey = I.Name;
                                    var itemValue = http://www.mamicode.com/I.GetValue(item, null);
                                    if (code.ToString() == itemKey.Replace("_", "."))
                                    {
                                        p.SetValue(entiey, itemValue, null);
                                    }
                                }
                            }
                        }
                    }
                }

类 映射 遍历大全