Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Here is the code that is throwing the error : how to resolve it.



C#
var patActivity = _ngDbContext.PATIENTACTIVITies.Where(x => x.CompanyID == RXDF.Constants.CompanyId

                   && x.ClientID == DataFeed.SPPeReferralOutbound.Ids.ClientId
                   && x.ProgramID == DataFeed.SPPeReferralOutbound.Ids.ProgramId
                   && x.PatientID == Convert.ToDecimal(row["CimplicityPatientCaseID"])
                   && x.CaseID == Convert.ToDecimal(row["CaseID"])
                   && x.PatActID == Convert.ToDecimal(row["PatActID"])).SingleOrDefault();



Thanks In Advance.
Posted
Comments
Krunal Rohit 30-Nov-15 2:45am    
What ?

-KR

Difficult to say with so little information, but a guess is that one of the columns in the variable row is set to null.

Change from
C#
Convert.ToDecimal(row["CimplicityPatientCaseID"])

to
C#
DBNull.Value.Equals(row["CimplicityPatientCaseID"]) ? 0 : Convert.ToDecimal(row["CimplicityPatientCaseID"])


and do the same for the other columns, CaseID and PatActID.
 
Share this answer
 
Comments
raxhemanth 30-Nov-15 3:05am    
Thankyou jonsson
It seems some of column data is null. So in order to avoid use code like below:
C#
x.PatientID == (Convert.IsDBNull(row["CimplicityPatientCaseID"])? 0 : Convert.ToDecimal(row["CimplicityPatientCaseID"]));

Note: Do the same for other two columns CaseID and PatActID
 
Share this answer
 
Comments
raxhemanth 30-Nov-15 3:05am    
Thankyou manas
[no name] 30-Nov-15 3:08am    
Welcome :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900