title: Source: MySql.Data.Entity.EF6 Index was outside the bounds of the array
body: <p>Source: MySql.Data.Entity.EF6 stored procedure generate error Index was outside the bounds of the array.</p>
  
  <p><a href="https://i.stack.imgur.com/w20Ti.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/w20Ti.png" alt="enter image description here"></a></p>
  
  <pre><code>  List&lt;PayRollAllocationList&gt; payroll = db.SP_EmployeePayRoll(orgCode, Medicalallowcode, HouseRentallowcode, HomeLoanInterest, Sect80allowcode, Childallowcode, Mediclaimallowcode, convallowcode, Miscellaneous, fromMonthValue, fromYearValue, toMonthValue, toYearValue, startDateValue, endDateValue)
                  .Select(x =&gt; new PayRollAllocationList
                  {
                      BankAccNo = x.BankAccountNo,
                      BankName = x.BankName,
                      BankIFSCCode = x.BankIFSCCode,
                      estatus = x.Status,
                      PayrollMonth = x.Month,
                      Year = x.Year,
                      EmployeeName = x.EmpoyeeName,
                      Designation = x.Designation,
                      JoiningDate = x.JoiningDate,
                      payconveyance = x.ConveyanceAndInternetReimbursement,
                      PayMedicalAllow = x.MedicalAllowance,
                      PayHouseAllow = x.HouseRentAllowance,
                      PayHomeLoanInterest = x.HomeLoanInterest,
                      PaySectionAllow = x.MonthlyInvestments,
                      Paychildedu = x.ChildrenEducationAllowance,
                      Paymediclaim = x.Mediclaim,
                      ////miscellaneous = db.salarymasters.Where(t =&gt; t.ApplicationUserID == x.ApplicationUserID &amp;&amp; t.AllowanceTypeID == Miscellaneous &amp;&amp; t.IsActive == true &amp;&amp; t.applicationuser.organizationmaster.OrganizationCode == orgCode).Select(t =&gt; t.Amount) != null ? db.salarymasters.Where(t =&gt; t.ApplicationUserID == x.ApplicationUserID &amp;&amp; t.AllowanceTypeID == Miscellaneous &amp;&amp; t.IsActive == true &amp;&amp; t.applicationuser.organizationmaster.OrganizationCode == orgCode).Select(t =&gt; t.Amount).Sum() : 0,
                      Paymiscellaneous = x.Miscellaneous,
                      PayBasicSalary = x.Basic,
                      PayIncentive = x.TotalCompensation,
                      PayTDSDeduction = string.IsNullOrEmpty(x.TDS) ? "0" : x.TDS,
                      PayEmployeeESIC = x.EmployeeESIC,
                      PayEmployerESIC = x.EmployerESIC,
                      PayEmployeePF = x.EmployeePF,
                      PayEmployerPF = x.EmployerPF,
                      TotalESIC = (!string.IsNullOrEmpty(x.EmployeeESIC) ? Convert.ToDecimal(x.EmployeeESIC) + (!string.IsNullOrEmpty(x.EmployerESIC) ? Convert.ToDecimal(x.EmployerESIC) : 0) : 0),
                      TotalPF = (!string.IsNullOrEmpty(x.EmployeePF) ? Convert.ToDecimal(x.EmployeePF) + (!string.IsNullOrEmpty(x.EmployerPF) ? Convert.ToDecimal(x.EmployerPF) : 0) : 0),
                      PayProfessionalTax = string.IsNullOrEmpty(x.ProfessionalTax) ? "0" : x.ProfessionalTax,
                      PayNonTaxableAmount = x.TotalNonTaxable,
                      PayTaxableAmount = x.TotalTaxableCompensation,
                      PaysalaryandConv = x.SalaryConveyance,
                      Paytotalcompensation = x.TotalCompensation,
                      PayNetSalary = x.NetPayble,
                      PayprojectIncentive = x.ProjectIncentive,
                      PayOTIncentive = x.OTIncentive,
                      PayAdjustAmt = x.AdjustmentAmount,
                      AdjustDesc = x.AdjustmentDescriptiom,
                      PayLWPAmt = x.LWP,
                  }).ToList();
  </code></pre>
  
  <p>at MySql.Data.Entity.EFMySqlDataReader.GetDataTypeName(Int32 ordinal)
  atSystem.Data.Entity.Core.Objects.Internal.BufferedDataRecord.ReadMetadata(String providerManifestToken, DbProviderServices providerServices, DbDataReader reader)
     at System.Data.Entity.Core.Objects.Internal.ShapedBufferedDataRecord.Initialize(String providerManifestToken, DbProviderServices providerServices, DbDataReader reader, Type[] columnTypes, Boolean[] nullableColumns)
     at System.Data.Entity.Core.Objects.Internal.BufferedDataReader.Initialize(String providerManifestToken, DbProviderServices providerServices, Type[] columnTypes, Boolean[] nullableColumns)
     at System.Data.Entity.Core.Objects.ObjectContext.CreateFunctionObjectResult[TElement](EntityCommand entityCommand, ReadOnlyCollection<code>1 entitySets, EdmType[] edmTypes, ExecutionOptions executionOptions)
     at System.Data.Entity.Core.Objects.ObjectContext.&lt;&gt;c__DisplayClass45</code>1.b__44()
     at System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction[T](Func<code>1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess)
     at System.Data.Entity.Core.Objects.ObjectContext.&lt;&gt;c__DisplayClass45</code>1.b__43()
     at System.Data.Entity.Infrastructure.DefaultExecutionStrategy.Execute[TResult](Func<code>1 operation)
     at System.Data.Entity.Core.Objects.ObjectContext.ExecuteFunction[TElement](String functionName, ExecutionOptions executionOptions, ObjectParameter[] parameters)
     at System.Data.Entity.Core.Objects.ObjectContext.ExecuteFunction[TElement](String functionName, MergeOption mergeOption, ObjectParameter[] parameters)
     at System.Data.Entity.Core.Objects.ObjectContext.ExecuteFunction[TElement](String functionName, ObjectParameter[] parameters)
     at OMS.omsdbEntities.SP_EmployeePayRoll(String orgCode, Nullable</code>1 medicalallowcode, Nullable<code>1 houseRentallowcode, Nullable</code>1 homeLoanInterest, Nullable<code>1 sect80allowcode, Nullable</code>1 childallowcode, Nullable<code>1 mediclaimallowcode, Nullable</code>1 convallowcode, Nullable<code>1 miscellaneous, Nullable</code>1 fromMonthValue, Nullable<code>1 fromYearValue, Nullable</code>1 toMonthValue, Nullable<code>1 toYearValue, Nullable</code>1 startDateValue, Nullable`1 endDateValue) in F:\Pooja\OMS\OMS\OMS\OMS_data.Context.cs:line 185
     at OMS.Service.ReportService.GetPayRollAllocationList() in F:\Pooja\OMS\OMS\OMS\Service\ReportService.cs:line 132</p>