加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读