Check Google, this approach can solve
My stored procedure is this:
CREATE procedure Cal_month_dep_fast @begdt datetime, @endt datetime
As
。。。。。。。。。
Select Dep_no, Prod_no, Batch_no, Prod_add, Dep_date, Dep_num, Inv_num,lest_num, Buy_price from #tempresult
The LINQ to SQL can be resolved by the following methods
1 Build a Class (remember to be public, otherwise error)
Using System;
Using System.Collections.Generic;
Using System.Linq;
Using System.Text;
Using System.Data.Linq.Mapping;
Using System.Linq.Expressions;
Namespace SBSC
{
[Table]
public partial class Myproc_result
{
Public Myproc_result () {}
[Column]
public string dep_no;
[Column]
public string prod_no;
[Column]
public string batch_no;
[Column]
public string Prod_add;
[Column]
Public DateTime dep_date;
[Column]
public decimal dep_num;
[Column]
public decimal inv_num;
[Column]
public decimal lest_num;
[Column]
public decimal buy_price;
}
}
2 then add the following in the Designer.cs file for DBML in LINQ: Remember that the name may be slightly changed from the previous stored procedure name
[Function (Name = "Dbo.cal_month_dep_fast")]
Public ienumerable<myproc_result> cal_month_dep_fast2 (datetime BEGDT, datetime endt)
{
Iexecuteresult result = this. Executemethodcall (This, ((MethodInfo) (Methodinfo.getcurrentmethod ())), BEGDT, Endt);
return result. ReturnValue as ienumerable<myproc_result>;
}
That's it.
How LINQ to SQL executes a stored procedure and returns a temporary table of stored procedures