/// <summary>Convert from VoluntaryPlanWaiverRequest entity to DTO</summary> /// <param name="dbContext">DB Context to use for setting DTO state</param> /// <param name="dto">DTO to use if already created instead of creating new one (can be inherited class instead as opposed to base class)</param> /// <param name="entityDtos">Used internally to track which entities have been converted to DTO's already (to avoid re-converting when circularly referenced)</param> /// <returns>Resultant VoluntaryPlanWaiverRequest DTO</returns> public VoluntaryPlanWaiverRequestDto ToDtoDeep(FACTS.Framework.DAL.DbContext dbContext, VoluntaryPlanWaiverRequestDto dto = null, Dictionary <BaseEntity, FACTS.Framework.Dto.BaseDto> entityDtos = null) { entityDtos = entityDtos ?? new Dictionary <BaseEntity, FACTS.Framework.Dto.BaseDto>(); if (entityDtos.ContainsKey(this)) { return((VoluntaryPlanWaiverRequestDto)entityDtos[this]); } dto = ToDto(dto); entityDtos.Add(this, dto); System.Data.Entity.Infrastructure.DbEntityEntry <VoluntaryPlanWaiverRequest> entry = dbContext?.Entry(this); dto.IsNew = (entry?.State == EntityState.Added); dto.IsDeleted = (entry?.State == EntityState.Deleted); if (entry?.Reference(x => x.Employer)?.IsLoaded == true) { dto.Employer = Employer?.ToDtoDeep(dbContext, entityDtos: entityDtos); } if (entry?.Reference(x => x.Form)?.IsLoaded == true) { dto.Form = Form?.ToDtoDeep(dbContext, entityDtos: entityDtos); } if (entry?.Collection(x => x.VoluntaryPlanWaiverRequestTypes)?.IsLoaded == true) { foreach (VoluntaryPlanWaiverRequestType voluntaryPlanWaiverRequestType in VoluntaryPlanWaiverRequestTypes) { dto.VoluntaryPlanWaiverRequestTypes.Add(voluntaryPlanWaiverRequestType.ToDtoDeep(dbContext, entityDtos: entityDtos)); } } return(dto); }
/// <summary>Convert from AddressLink entity to DTO</summary> /// <param name="dbContext">DB Context to use for setting DTO state</param> /// <param name="dto">DTO to use if already created instead of creating new one (can be inherited class instead as opposed to base class)</param> /// <param name="entityDtos">Used internally to track which entities have been converted to DTO's already (to avoid re-converting when circularly referenced)</param> /// <returns>Resultant AddressLink DTO</returns> public AddressLinkDto ToDtoDeep(FACTS.Framework.DAL.DbContext dbContext, AddressLinkDto dto = null, Dictionary <BaseEntity, FACTS.Framework.Dto.BaseDto> entityDtos = null) { entityDtos = entityDtos ?? new Dictionary <BaseEntity, FACTS.Framework.Dto.BaseDto>(); if (entityDtos.ContainsKey(this)) { return((AddressLinkDto)entityDtos[this]); } dto = ToDto(dto); entityDtos.Add(this, dto); System.Data.Entity.Infrastructure.DbEntityEntry <AddressLink> entry = dbContext?.Entry(this); dto.IsNew = (entry?.State == EntityState.Added); dto.IsDeleted = (entry?.State == EntityState.Deleted); if (entry?.Reference(x => x.Address)?.IsLoaded == true) { dto.Address = Address?.ToDtoDeep(dbContext, entityDtos: entityDtos); } if (entry?.Reference(x => x.Employer)?.IsLoaded == true) { dto.Employer = Employer?.ToDtoDeep(dbContext, entityDtos: entityDtos); } if (entry?.Reference(x => x.EmployerUnit)?.IsLoaded == true) { dto.EmployerUnit = EmployerUnit?.ToDtoDeep(dbContext, entityDtos: entityDtos); } return(dto); }