1
public static IEnumerable<HospitalEntities> GetAllHospitalDetails(HospitalRequest hospitalRequest)
{
    CommonClass commonClass = new CommonClass();
    try
    {
        return Mapper.Map<IEnumerable<HospitalDto>, List<HospitalEntities>>(new HealthServiceClient().GetAllHospitalDetails(new HospitalRequestDto
        {
            ApplicationContext = Mapper.Map<ApplicationContext, ApplicationContextDto>(commonClass.ApplicationContext),
            TenantContext = Mapper.Map<TenantContext, TenantContextDto>(commonClass.TenantContext),
            UserContext = Mapper.Map<UserContext, UserContextDto>(commonClass.UserContext),
            SelectedTenantId = hospitalRequest.SelectedTenantId,
            hospitalDto = Mapper.Map<HospitalEntities, HospitalDto>(hospitalRequest.hospitals)
        }).hospitalResponseDto);
    }
    catch (Exception Ex)
    {
        ExceptionPolicy.HandleException(Ex, ExceptionPolicies.UI_POLICY, (Int32)ExceptionConstant.EventId.ERR_UI_HEALTH_HealthServiceHelper_GetAllHospitalDetails, "ManageVaccinationMaster.aspx", Conversion.ConvertToString(commonClass.TenantContext.TenantId), Conversion.ConvertToString(commonClass.TenantContext.ClientCode), Conversion.ConvertToString(commonClass.UserContext.UserId));
        throw Ex;
    }
}

Is this approach right? Does WCF connection remain opened? Is it good to access WCF service from static class?

Ilya Chumakov
  • 23,161
  • 9
  • 86
  • 114
skj123
  • 54
  • 1
  • 6
  • What is the actual problem you try to resolve? You may close the channel manually http://stackoverflow.com/a/2441595/5112433 – Ilya Chumakov May 10 '16 at 17:26
  • 1)I have create static helper class(static methods) to access all wcf service----Is there any memory related concerns are there(w3wp.exe) 2)Is there any effect in writing return Mapper.Map, List>(new HealthServiceClient().GetAllHospitalDetails(new HospitalRequestDto {... Since here channel is not getting close – skj123 May 11 '16 at 04:44

0 Answers0