performance issue array of sub class and nested sub class

May 13, 2013 at 1:38 PM
hi,

i have converted one class to another class using Emit mapper , converted successfully but conversion is very slow.

please check my code and give me a suggestion.

Thanks in advance

How to convert efficiently array of sub class and nested class using emit mapper?

 // here getting data from DB


 FirmBO firm = LoadData(318);

// converting BO to DC class

var firmBO = ObjectMapperManager
  .DefaultInstance
  .GetMapper<FirmBO, FirmDC>(
      new DefaultMapConfig()
      .MatchMembers((m1, m2) => m1 == m2)     
       .ConvertUsing<FAFDate, DateTime>(v => v.MMDDYYYY != "" ? Convert.ToDateTime(v.MMDDYYYY) : Convert.ToDateTime(null))

        
        .ConvertUsing<BOCollection, FirmLocationDC[]>(v => ObjectMapperManager.DefaultInstance.GetMapper<FirmLocationBO[], FirmLocationDC[]>(new DefaultMapConfig()
        .MatchMembers((m1, m2) => m1 == m2)
        .ConvertUsing<FAFDate, DateTime>(v5 => v5.MMDDYYYY != "" ? Convert.ToDateTime(v5.MMDDYYYY) : Convert.ToDateTime(null))
            .ConvertUsing<BOCollection, FirmLocationJurisdictionByFirmLocationIdDC[]>(v1 => ObjectMapperManager.DefaultInstance.GetMapper<FirmLocationJurisdictionByFirmLocationIdBO[], FirmLocationJurisdictionByFirmLocationIdDC[]>(new DefaultMapConfig()
            .MatchMembers((m1, m2) => m1 == m2)
                 .ConvertUsing<FAFDate, DateTime>(v6 => v6.MMDDYYYY != "" ? Convert.ToDateTime(v6.MMDDYYYY) : Convert.ToDateTime(null))                 
                ).Map(v1.Cast<FirmLocationJurisdictionByFirmLocationIdBO>().ToArray()))
            ).Map(v.Cast<FirmLocationBO>().ToArray()))


  );

// convert from BO to DC

FirmDC hc = firmBO.Map(firm);





// BO classes and array of sub classes and array of Nested subclasses 
 public class FirmBO : BusObj
    {
       
        [BOCollection(typeof(FirmLocationBO))]
        public BOCollection FirmLocations { get; }
        public int FirmStatusCodeID { get; set; }       
       
    }

  public class FirmLocationBO : BusObj
    {        

        public int AdminGroupID { get; set; }       
        [BOCollection(typeof(FirmLocationJurisdictionByFirmLocationIdBO))]
        public BOCollection FirmLocationJurisdictions { get; }
        public int FirmLocationStatusCodeID { get; set; }       
        public string ShipToZip { get; set; }
        public FAFDate StarsBatchRunDT { get; set; }

    }

   public class FirmLocationJurisdictionByFirmLocationIdBO : BusObj
    {
      
        public int JacketUnderwriterID { get; set; }
        public string JurisdictionStateCode { get; set; }
        [BOCollection(typeof(CountyByAccountBO), "FirmLocationJurisdictionID")]
        public BOCollection LicensedCounties { get; }       
        public FAFDate StarsBatchRunDT { get; set; }   

    }

  public class CountyByAccountBO : CountyBO
    {       
        public int CreatedByUserId { get; set; }
        public FAFDate CreatedDate { get; set; }
        public int FirmLocationJurisdictionId { get; set; }

    }


// DC classes and array of sub classes and array of Nested subclasses 

 public class FirmDC
    {
      
        public FirmLocationDC[] FirmLocations { get; }
        public int FirmStatusCodeID { get; set; }       
       
    }

  public class FirmLocationDC
    {        

        public int AdminGroupID { get; set; } 
        public FirmLocationJurisdictionByFirmLocationIdDC[] FirmLocationJurisdictions { get; }
        public int FirmLocationStatusCodeID { get; set; }       
        public string ShipToZip { get; set; }
        public FAFDate StarsBatchRunDT { get; set; }

    }

   public class FirmLocationJurisdictionByFirmLocationIdDC
    {
      
        public int JacketUnderwriterID { get; set; }
        public string JurisdictionStateCode { get; set; }       
        public CountyByAccountDC[] LicensedCounties { get; }       
        public FAFDate StarsBatchRunDT { get; set; }   

    }

  public class CountyByAccountDC
    {       
        public int CreatedByUserId { get; set; }
        public FAFDate CreatedDate { get; set; }
        public int FirmLocationJurisdictionId { get; set; }

    }