0

In my ASP.NET Web API project, I am trying to use the generic repositories with the List objects under one of the methods. But it is throwing exception

Exception thrown: 'System.Data.SqlClient.SqlException' in System.Data.dll System.Data.Entity.Core.EntityCommandExecutionException: Calling 'Read' when the data reader is closed is not a valid operation. ---> System.Data.SqlClient.SqlException: Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding. ---> System.ComponentModel.Win32Exception: The wait operation timed out

lstFinalResult object contains few rows. partnerRepo is a generic repo and will have data at the later stage, i suppose.

Please advise, where am i making the mistake. Can we mix the List with generic repository objects in the linq query ?

Here is the linq code :-

    List<UserDocumentResult> lstFinalResult = new List<UserDocumentResult>();

        foreach (DocumentMapping dm in lstMappings)
        {
            lstFinalResult.Add(new UserDocumentResult { PID = dm.PartnerID,
                DocMappingID = dm.DocumentMappingID,
                EntityType = "",
                Name = ""
            });
        }


        var partnerRepo = _docRepository.PtGenericRepo.Get();
        var entityCodesRepo = _docRepository.EntityCodeGenericRepo.Get();


---While debugging, I am getting error in the below code only. 

 var qualifiedPartnerSet = (from tmp in lstFinalResult
                            join px in partnerRepo on tmp.PID equals px.PartnerID
                           join ecx in entityCodesRepo on px.EntityCodeID equals ecx.EntityCodeID

                      select new UserDocumentResult
                       {
                         PID = px.PartnerID,
                         MappingID = tmp.MappingID,
                         EntityType = ecx.DisLabel.Trim(),
                         Name = px.NameLine1.Trim() + px.NameLine2.Trim(),
                         }).ToList();
Sahil Sharma
  • 1,813
  • 1
  • 16
  • 37
Karan
  • 3,265
  • 9
  • 54
  • 82

0 Answers0