I'm running a stored procedure through L2S and it's returning 'Specified cast is not valid'. The stored proc is returning data when ran manually and when I step thru it, everything is fine until it tries to create the row object in "foreach (var row in result)".
var q = new db();
var result = q.GetNearbyLocations(latitude, longitude,searchDistance);
foreach (var row in result)
{
var c = new Clinic()
{
Name = row.CLINIC_NAME.Trim(),
Ad开发者_开发技巧dress1 = row.DRADR1.Trim()...
Ideas?
That is usually caused by a data type mismatch, e.g. if the stored procedure returns a int and that is mapped to a string, or if the stored proc return a varchar(1) and that is mapped to a System.Char.
Your sporc isn't actually invoked until a foreach
statement is executed. Therefore, ensure that LINQ to SQL can correctly map data returned from the sproc to your objects.
精彩评论