I need to find a way of using stored procedure in dynamic data's web site. For example on Northwind database I create stored procedure create procedure UpdateCategories as CategoryID int... ... And In Linq to SQL designer I was created Data Function "UpdateCategories"
How can I applay my Data Function in my project for Update my Categories?
In this example the Contact table is driven by stored procedures. Here are the basic steps:
1) Create a Insert, Delete and Update stored procedure. The drag them into the Linq to SQL designer.
2) Click on the entity you want to associate the stored procedures to, in the property window (F4) there will be Insert, Update and Delete options you can select. Select each and associate them to your stored procedures from step 1.
3) For the List page you want to override create a directory based on the table name in the DynamicData\CustomPages directory, drag the List.aspx from the DynamicData\PageTemplates into this directory.
4) Write a stored procedure that does all the operations you want to support. To fully support Dynamic Data it should do paging, sorting and filtering (if their are any foreign key tables). You will need to manually add this stored procedure to the generated
Linq to SQL datacontext using a partial class.
5) In the List.aspx you will need to override the OnSelecting event from the LinqDataSource and call the stored procedure from setp 4 passing the paging, sorting and filter options.
The sample I've provided does all of these steps for the Contact table. The Linq to SQL model has references to the Insert and Delete stored procedures. The Contact entity in the Linq to SQL model has the stored procedures associated with the Insert, Update
and Delete operations, there is a custom page for the Contact List.aspx. it has an override of the OnSelecting event that calls the Get stored procedure passing the appropriate parameters and the data context is extended in a partial class to contain the call
for the Get stored procedure.
This is alot of work but if you are used to using stored procedures these are the same things you would do outside of Linq to SQL.
Balyk
Member
7 Points
31 Posts
using of stored procedure
Aug 29, 2008 11:41 AM|LINK
ASP.NET Dynamic Data stored procedure
scothu
Participant
1436 Points
291 Posts
Microsoft
Moderator
Re: using of stored procedure
Sep 02, 2008 08:10 PM|LINK
You can see a sample of using stored procedures with Linq to SQL and Dynamic Data at our samples page: http://www.codeplex.com/aspnet/Release/ProjectReleases.aspx?ReleaseId=14473
In this example the Contact table is driven by stored procedures. Here are the basic steps:
1) Create a Insert, Delete and Update stored procedure. The drag them into the Linq to SQL designer.
2) Click on the entity you want to associate the stored procedures to, in the property window (F4) there will be Insert, Update and Delete options you can select. Select each and associate them to your stored procedures from step 1.
3) For the List page you want to override create a directory based on the table name in the DynamicData\CustomPages directory, drag the List.aspx from the DynamicData\PageTemplates into this directory.
4) Write a stored procedure that does all the operations you want to support. To fully support Dynamic Data it should do paging, sorting and filtering (if their are any foreign key tables). You will need to manually add this stored procedure to the generated Linq to SQL datacontext using a partial class.
5) In the List.aspx you will need to override the OnSelecting event from the LinqDataSource and call the stored procedure from setp 4 passing the paging, sorting and filter options.
The sample I've provided does all of these steps for the Contact table. The Linq to SQL model has references to the Insert and Delete stored procedures. The Contact entity in the Linq to SQL model has the stored procedures associated with the Insert, Update and Delete operations, there is a custom page for the Contact List.aspx. it has an override of the OnSelecting event that calls the Get stored procedure passing the appropriate parameters and the data context is extended in a partial class to contain the call for the Get stored procedure.
This is alot of work but if you are used to using stored procedures these are the same things you would do outside of Linq to SQL.
PM, ASP.NET Team, Microsoft
dilip0165
Member
8 Points
6 Posts
Re: using of stored procedure
Jan 31, 2012 11:00 AM|LINK
Hi here I have decsribe how to create a dynamic page using procedure.
it is very useful to make a dynamic page by just using a stored procedure.
http://sqldebate.blogspot.in/2012/01/how-to-create-dynamic-page-using-ms-sql.html
in above link i have made a dynamic procedure which is very easy to perform .