Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Feb 24, 2012 10:28 AM by sravanisrav
Feb 22, 2012 03:40 AM|LINK
Actually I just installed .net 4.0, so I want to use linq in my application. I know how to create store procedure, but how ti use linq to create store procedure( for all 3 purpose insert, update, delete). let me know please.
Feb 22, 2012 03:59 AM|LINK
Use this link For stored procedure with linq
Feb 22, 2012 08:53 AM|LINK
I have created class file named Leave.dbml.
and also created a sp
ALTER PROCEDURE dbo.Insert_Leave
insert into mtbl_Leave_Data(User_Id, Dept_To, Leave_Type, Total_Leave_HR, Leave_From, Leave_To, Leave_Half_Full, Comments, Leave_Status ) values (@User_Id, @Dept_To, @Leave_Type, @Total_Leave_HR, @Leave_From, @Leave_To, @Leave_Half_Full, @Comments, @Leave_Status )
now here 2 classes I have regading this Leave.dbml LeaveDataContext and my table mtbl_Leave_Data and also have a form where I have controls like textbox calendar etc.
This is I done through your link. But later this tutorial goes out of my mind as I am new to do this. so could you please
tell me through some coding how can I insert data, I am not saying put full code but just an example.
before this I used to insert data using command object like
sqlcommand com =new sqlcommand("sp" ,connection)
com.parameters.add(...........).value = textbox1.text
Could you please
Feb 22, 2012 11:09 AM|LINK
From serverexplorer drop your stored procedure into rigt side window of Leave.dbml page
In Leave.dbml page right click on the mtbl_Leave_Data(Your Table) ->configurebehaviour
class(choose your table name)
Click on the customize(Choose your stored Procedure)
and set the method arguments and class properties
after that in your code file
Leave ctx1 = new Leave ();
mtbl_Leave_Data d = new mtbl_Leave_Data();
sorry i just do a writing mistake.
And actually it is a power of linq by which stored procedure automatically call,as yo configure behaviour of table for insert operation by the
method that i told you in the starting
Feb 23, 2012 02:23 AM|LINK
what is "s" in this code ( s.InsertOnSubmit(d)) and where did you use store procedure ..?
Feb 23, 2012 03:51 AM|LINK
See above, my updated answer
Feb 23, 2012 04:25 AM|LINK
See above, my updated answer
thanks for correcting , but where is sp...?
Feb 23, 2012 04:36 AM|LINK
it is a power of linq by which stored procedure automatically call,when you configure behaviour of table for insert operation
by the method that i told you in the starting, after that every time when you insert by the linq method then automatically stored procedure is
called,(you can see this by tracing the sql server )
Feb 23, 2012 04:37 AM|LINK
Feb 23, 2012 06:17 AM|LINK
it is a power of linq by which stored procedure automatically call,when you configure behaviour of table for insert operation by the method that i told you in the starting, after that every time when you insert by the linq method then automatically stored procedure
is called,(you can see this by tracing the sql server )
but how it would know which sp need to call and which not as we did not mention the sp name...?