c# – 如何将两个类合并为一个单元?
发布时间:2020-12-15 22:03:36 所属栏目:百科 来源:网络整理
导读:ListReportDataInfo Lrdi = new ListReportDataInfo();ReportDataInfo rdi = new ReportDataInfo();ReportDataInfo RdiMerge=new ReportDataInfo();string[] AccountTypeCodeCustomArray = AccountCodeTypeCustom.Split(",".ToCharArray());string[] SubType
List<ReportDataInfo> Lrdi = new List<ReportDataInfo>(); ReportDataInfo rdi = new ReportDataInfo(); ReportDataInfo RdiMerge=new ReportDataInfo(); string[] AccountTypeCodeCustomArray = AccountCodeTypeCustom.Split(",".ToCharArray()); string[] SubTypeCodeCustomArray = SubAccountTypeCodeCustom.Split(",".ToCharArray()); string[] AccountCodeCustomArray = AccountCodeCustom.Split(",".ToCharArray()); for (int i = 0; i < AccountCodeTypeCustom.Length; i++) { rdi = ExportDataToCSV.GetLedgerReportData(Globals.GetInt( AccountTypeCodeCustomArray[i],0),Globals.GetInt( SubTypeCodeCustomArray[i],Globals.GetInt( AccountCodeCustomArray[i],this.CurrentSessionInfo.Company.CompanyCode,this.CurrentSessionInfo.FinancialYear.StartDate,this.CurrentSessionInfo.FinancialYear.EndDate); // Lrdi.Add(rdi); RdiMerge.Rows.Concat(rdi.Rows); //RdiMerge.ReportHeading = rdi.ReportHeading; //RdiMerge.Rows = rdi.Rows; } CurrentSessionInfo.ReportData = RdiMerge; 这是我以前尝试过的事情 现在我的问题是 无论从ExportDataToCSV.GetLedgerReportData()返回什么值,我都被困在这里; ReportDataInfolooks之类的 [Serializable] public class ReportDataInfo { public string ReportHeading { get; set; } public List<ReportColumnInfo> Rows { get; set; } } 解决方法
它只是使用Automapper
AutoMapper是一个对象到对象的映射器,它允许您解决将一种类型的一个对象中的相同属性映射到另一种类型的另一个对象的问题.例如,可以使用AutoMapper自动将重型实体Customer对象映射到CustomerDTO (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |