Linq: 'Specified cast is not valid' error exception.
Hi All,
Iâm in a big problem.
I'm using WCF service and LINQ for our Silverlight 2 application.
In my application I'm fetching records from the SQL database using the stored procedure. Below is the interface of my procedure
List<Usp_GetReportDataResult> GetReportData(int JobId, DateTime StartDate, DateTime EndDate)
For some JobId Iâm able to get the data successfully, but for most of the JobIds Iâm getting 'Specified cast is not valid' error exception. JobId is a unique key field of title table.
Below is the Web Method to get the result using LINQ statement:
publicList<Usp_GetReportDataResult> GetReportData(int JobId, DateTime StartDate, DateTime EndDate)
{
// Call to get record from the Database
WMDBDataContext db = newWMDBDataContext();
var matchingRecords = from Report in db.Usp_GetReportData(JobId, StartDate, EndDate)
select Report;
return matchingRecords.ToList(); //Error is coming in this line.
}
Below are the fields and datatypes generated by the LINQ Designer class for Usp_GetReportData.
privatestring _Status;
privatestring _Protocol;
privatestring _Country;
privatestring _CountryID;
privatestring _LanguageName;
privatestring _Subtitles;
private System.Nullable<short> _VideoID;
private System.Nullable<System.DateTime> _LastSeenDateET;
private System.Nullable<int> _DownloadCounts;
privatechar _AdjustedInd;
private System.Nullable<long> _FileSize;
private System.Nullable<byte> _HourNumber;
privatestring _IPAddress;
==========================================
Thanks,
Mahesh
|