I have found examples for using UPDATE, INSERT and DELETE Stored Procedures with Dynamic data however I can;t seem to find anything on using a Select Stored Procedure.
I have a Select Stored procedure that is fairly complex and pulls data from 6 differant tables using inner Joins. What's the bext way to use Dynamic Data with this type of Sproc?
You can view the Dynamic Data samples here:
http://www.codeplex.com/aspnet/Release/ProjectReleases.aspx?ReleaseId=14473. There is a sample called DynamicDataSProc which shows using stored procedures to do all the operations. Note that Linq to SQL supports things like paging, filtering, etc automatically
and when you move to a stored procedure you need to do all of this manually. See the example for details
Scott Hunter
PM, ASP.NET Team, Microsoft
Marked as answer by ricka6 on Feb 12, 2009 08:17 PM
Thank you for your respnse. Based on your answer my next question is ...
what is the best way to handle situations like this? I need to be able to display data from several Tables (using joins) in the same grid and be able to update and insert to those table also. Is there a way to handle this type of situation with LINQ to
SQL and/or Entities and Dynamic Data? I can do this by hand writing all the code but I'd love to find a more automated way...
Noam's blog on
Stored Procedure Mapping shows you how to do this with EF. I'm working on a dynamic data (DD) version. Note, this is really a L2S or EF question, not DD.
Mapping entities to multi-table joins to do updates is a difficult problem. You might try posting that on
Post LINQ To SQL Questions
here Post Entity Framework Questions here
Linq to SQL/Entity Framework are modeling tools and so for CRUD operatoins they expect the item to exist in the model. So lets say you want to have 3 fields from table A and 4 fields from table B. What you should do is create a new object in the modeling
tool that contains the items that you want. Then you would map your insert. update and delete stored procs to this new object your stored procedures. Now you can create a Linq query to bring back these objects and update them. Somewhere there has got to be
a tutorial on this.
Now what if you want to use a stored procedure such as the ones found in the Small Business kit, like the GetChildItems, how would you code this into Dynamic Data?
Just map sproc's to select/update/delete. Noam writes in
his blog:
At this time, the Entity Framework requires you to map all three stored procedures. You cannot map only the delete stored procedure. In addition, the entity type must still be mapped to a table, view, or query view.
putrtek@gmai...
Member
11 Points
8 Posts
How to use Select Stored Procedures with Dynamic Data
Feb 12, 2009 01:09 PM|LINK
I have found examples for using UPDATE, INSERT and DELETE Stored Procedures with Dynamic data however I can;t seem to find anything on using a Select Stored Procedure.
I have a Select Stored procedure that is fairly complex and pulls data from 6 differant tables using inner Joins. What's the bext way to use Dynamic Data with this type of Sproc?
-MARK-
ASP.NET Dynamic Data
putrtek@gmail.com
scothu
Participant
1436 Points
291 Posts
Microsoft
Moderator
Re: How to use Select Stored Procedures with Dynamic Data
Feb 12, 2009 05:21 PM|LINK
You can view the Dynamic Data samples here: http://www.codeplex.com/aspnet/Release/ProjectReleases.aspx?ReleaseId=14473. There is a sample called DynamicDataSProc which shows using stored procedures to do all the operations. Note that Linq to SQL supports things like paging, filtering, etc automatically and when you move to a stored procedure you need to do all of this manually. See the example for details
PM, ASP.NET Team, Microsoft
putrtek@gmai...
Member
11 Points
8 Posts
Re: How to use Select Stored Procedures with Dynamic Data
Feb 12, 2009 07:37 PM|LINK
Scott,
Thank you for your respnse. Based on your answer my next question is ...
what is the best way to handle situations like this? I need to be able to display data from several Tables (using joins) in the same grid and be able to update and insert to those table also. Is there a way to handle this type of situation with LINQ to SQL and/or Entities and Dynamic Data? I can do this by hand writing all the code but I'd love to find a more automated way...
Thanks again for your responses.
-MARK-
putrtek@gmail.com
ricka6
All-Star
15088 Points
2277 Posts
Microsoft
Moderator
Re: How to use Select Stored Procedures with Dynamic Data
Feb 12, 2009 09:23 PM|LINK
Noam's blog on Stored Procedure Mapping shows you how to do this with EF. I'm working on a dynamic data (DD) version. Note, this is really a L2S or EF question, not DD.
Mapping entities to multi-table joins to do updates is a difficult problem. You might try posting that on
Post LINQ To SQL Questions here
Post Entity Framework Questions here
scothu
Participant
1436 Points
291 Posts
Microsoft
Moderator
Re: How to use Select Stored Procedures with Dynamic Data
Feb 13, 2009 06:55 PM|LINK
Linq to SQL/Entity Framework are modeling tools and so for CRUD operatoins they expect the item to exist in the model. So lets say you want to have 3 fields from table A and 4 fields from table B. What you should do is create a new object in the modeling tool that contains the items that you want. Then you would map your insert. update and delete stored procs to this new object your stored procedures. Now you can create a Linq query to bring back these objects and update them. Somewhere there has got to be a tutorial on this.
PM, ASP.NET Team, Microsoft
ricka6
All-Star
15088 Points
2277 Posts
Microsoft
Moderator
Re: How to use Select Stored Procedures with Dynamic Data
Feb 13, 2009 07:41 PM|LINK
SeeTable Splitting”: Mapping multiple entity types to the same table.Actually that does the opposite and won't help. I'll see if I can find a tutorial.
putrtek@gmai...
Member
11 Points
8 Posts
Re: How to use Select Stored Procedures with Dynamic Data
Feb 13, 2009 07:50 PM|LINK
Thanks... appreciate anything you can find.
putrtek@gmail.com
nbrglobalinc
Member
25 Points
98 Posts
Re: How to use Select Stored Procedures with Dynamic Data
Mar 07, 2009 04:26 PM|LINK
Now what if you want to use a stored procedure such as the ones found in the Small Business kit, like the GetChildItems, how would you code this into Dynamic Data?
ricka6
All-Star
15088 Points
2277 Posts
Microsoft
Moderator
Re: How to use Select Stored Procedures with Dynamic Data
Mar 07, 2009 11:08 PM|LINK
Just map sproc's to select/update/delete. Noam writes in his blog:
At this time, the Entity Framework requires you to map all three stored procedures. You cannot map only the delete stored procedure. In addition, the entity type must still be mapped to a table, view, or query view.
You can also map sProcs in L2S
nbrglobalinc
Member
25 Points
98 Posts
Re: How to use Select Stored Procedures with Dynamic Data
Mar 08, 2009 02:08 AM|LINK
How would one code the SqlCatalogProvider into the Linq to Sql .dbml file? Preferrably VB?