c# - LINQ to Stored Procedure. Can I call the SP with a dynamic list of parameters instead of strongly typing them? -
I'm trying to make my code more dynamic so I currently call a stored procedure, such as some firmness With parameters typed with
var result = datacontex. Sputter (txtUserId.Text, txtUserFirstName.Text, txtUserListName.Text);
Now what I want to be capable of, connects the parameters through the loop and dynamically. So if I add another search field tomorrow, like a user address, or something in my panel, I can just loop through control and dynamically add the parameter and come back and stored the stored procedure firmly Can not change call.
Before LINQ, something that you will do with parameter.ad () on your stored functionality.
Is there a way to accomplish this, would it still use SQL from SQL?
ExecuteCommand
and ExecuteQuery
Code> DataContext classes take a simple parameter ( params object []
). Some people find something when they come up, but they work for the most part and there are fewer codes to write than comparing the parameters of a SqlCommand
.
Context.ExecuteCommand ("EXEC usp_UpdateProductName {0}, {1}", productID, productName);
All this really is for this.
Comments
Post a Comment