c# – 如何将两个类合并为一个单元?

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()返回合并返回的ReportDataInfo;

无论从ExportDataToCSV.GetLedgerReportData()返回什么值,我都被困在这里;
我想合并到单个ReportDataInfo然后传递给CurrentSessionInfo.ReportData = RdiMerge;

ReportDataInfolooks之类的

[Serializable]
public class ReportDataInfo
{
    public string Reportheading { get; set; }
    public List<ReportColumnInfo> Rows { get; set; }
}

解决方法

它只是使用Automapper

AutoMapper是一个对象到对象的映射器,它允许您解决将一种类型的一个对象中的相同属性映射到另一种类型的另一个对象的问题.例如,可以使用AutoMapper自动将重型实体Customer对象映射到CustomerDTO

相关文章

目录简介使用JS互操作使用ClipLazor库创建项目使用方法简单测...
目录简介快速入门安装 NuGet 包实体类User数据库类DbFactory...
本文实现一个简单的配置类,原理比较简单,适用于一些小型项...
C#中Description特性主要用于枚举和属性,方法比较简单,记录...
[TOC] # 原理简介 本文参考[C#/WPF/WinForm/程序实现软件开机...
目录简介获取 HTML 文档解析 HTML 文档测试补充:使用 CSS 选...