Last post Dec 10, 2015 06:33 AM by Nan Yu
Dec 10, 2015 04:18 AM|kia997997|LINK
I have created a stored querry and want to use it as the update method of my data source object.
Itried the following:
I created a class and wrote a function in that class (using the stored querry), so I can later use that function in my Data source object. But iget an error.
Here is the code and the error I get:
public class Bal
public Logbook getLogbookIDs1()
using (var context = new APSELOGDataContext())
But I get the following error:
Error 1 Cannot implicitly convert type 'System.Data.Linq.ISingleResult<ElogObjectBoundingTest.Logbook>' to 'ElogObjectBoundingTest.Logbook'. An explicit conversion exists (are you missing a cast?) C:\Users\ACER\Documents\Visual Studio 2010\Projects\APS\ElogApp\ElogObjectBoundingTest\ElogObjectBoundingTest\Bal.cs 42 24 ElogObjectBoundingTest
Any help is appreciated.
Dec 10, 2015 06:33 AM|Nan Yu|LINK
Hi kia ,
Welcome to ASP.NET Forum .
Since you use a stored procedure in LINQ, it'll generate a class T(procedure name + "Result") for you automatically to store the data. The returned type is always ISingleResult<T>.In your code, you need to use
ISingleResult<T> to receive your data retrieved from the stored procedure. ISingleResult<T> can't be converted to "Logbook" type and caused the problem. Here's the sample code:
ISinlgeResult<Logbook> books= context.sp_GetLogbooks();
foreach(Logbook value in books)
For more details ,please refer to below article: