Click here to Skip to main content
14,767,229 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Everyone :)

I have been using LINQ and would like advice on how to use LINQ for inserting data.

I have reviewed some articles on how to use insert SPROCS with LINQ.

I am trying to get down to the basics here.

I have an SPROC called Client_Insert. Now the articles that I have read advice me to add the Client table (in this case) to the OR mapper and specify the Insert property to Customize and mention the SPROC for adding data to the Client table.

I simply wish to pass the parameters to the SPROC and execute it using LINQ.

Questions.
1. As I understand the only reason to use the OR mapper (as mentioned above) is to restrict adding the data through an SP only. Is this correct?

2. I want to create a helper function that executes an SP within the LINQ framework and using a (DBTransaction) transaction. If I were not using LINQ I would be passing an array of SQLParameters
e.g.
SqlParameter[] Myparam

How will I pass parameters to a helper function that executes an insert SP using the LINQ freamework?


3. Please give me any other useful advice :)

Have a great day!!
Posted
Updated 4-Oct-10 9:42am
v2

1 solution

I don't know if this answers your question or not.

When using a stored procedure in linq you pass the required parameters in brackets e.g.

string result = fdc.ProcInsertTransactions(Par1,Par2,Par3).ToString();


if you require a transaction the best option would be to do it on the proc side within SQL.
   
Comments
RebornDeveloper 7-Oct-10 1:55am
   
HI

The part about the transaction on the server side was of great help. I should have thought of that.

But as far as the parameters go, let me repeat the question....
If I were using SQLPARAMETER and i were to write a helper function, then i could pass an array of sqlparams to that helper function.

if i am using a dc and i want to pass params to the helper functionm then how do i do so?

I know that i can use an object array, but i dont want to

thanks
milenalukic 7-Oct-10 14:22pm
   
I don't quite understand what you mean by dc and helper function.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900