I'm trying to write the SqlCatalogProvider into my Database.dbml file but I don't know exactly how to code it, or to make a new class of it, preferrably in VB. Thank you!!!
I have never used the SqlCatalogProvider but presumably it has a number of tables in the DB all you would do is drag them onto the design surface of the dbml file you would need to provide you own custom logic to simulate the rest of the provider functionality
(same for c# or VB) DD would then give you an admin tool to add data to any of the table ensuring relationships.
Dynamic DataSqlCatalogProvider
See my blog C# Bits | Twitter @sjnaughton Always seeking an elegant solution.
All right, cool, think I've found a way around the SqlCatalogProvider problem but now I get a Error 1 Too many arguments to 'Public Sub New()'. from:
While r.Read()
If TypeOf r("id") Is DBNull Or TypeOf r("visible") Is DBNull Or TypeOf r("title") Is DBNull Then
Throw New InvalidOperationException(Messages.ItemRequiredAttributesMissing)
End If
curr = New Item(CStr(r("id")), CType(r("visible"), [Boolean]), CStr(r("title")))
curr.Description = Util.ReturnEmptyStringIfDbNull(r("description"))
curr.NavigateUrl = Util.ReturnEmptyStringIfDbNull(r("navigateUrl"))
curr.ImageUrl = Util.ReturnEmptyStringIfDbNull(r("imageUrl"))
curr.ImageAltText = Util.ReturnEmptyStringIfDbNull(r("imageAltText"))
list.Add(curr)
End While
All right, after a couple days of tweaking and deleting several classes, I think I have found the problem, which to me seems to be the easiest after all the coding I did. When you move the tables and SPROCs from the SQL database into the Data.dbml, it
will automatically take the id, visible, title, etc. so you can go ahead and delete the Item.vb(cs) class and the Category.vb(cs) class since the variables are declared in the data.dbml designer. Now in the Catalog.vb(cs), CatalogProvider.vb(cs), and SqlCatalogProvider.vb(cs)
classes, I added an Import DataContext. The DataContext is found in the .dbml class file as part of the partial public class. And just to be on the safe side, I added it to the Messages, DataProvidersSection, ProviderSettingsValidation, and Util classes.
And for the Items.aspx behind code, I also added the Import DataContext. When I go to run, it all works! :) [Yes]. So now instead of manually typing everything into an Xml file, I can just add it through Dynamic Data into my tables. Thanks to everyone for
looking and responding!
nbrglobalinc
Member
25 Points
98 Posts
Help w/ Small Business Kit and DD
Mar 08, 2009 02:20 AM|LINK
I'm trying to write the SqlCatalogProvider into my Database.dbml file but I don't know exactly how to code it, or to make a new class of it, preferrably in VB. Thank you!!!
sjnaughton
All-Star
27308 Points
5458 Posts
MVP
Re: Help w/ Small Business Kit and DD
Mar 08, 2009 11:06 AM|LINK
I have never used the SqlCatalogProvider but presumably it has a number of tables in the DB all you would do is drag them onto the design surface of the dbml file you would need to provide you own custom logic to simulate the rest of the provider functionality (same for c# or VB) DD would then give you an admin tool to add data to any of the table ensuring relationships.
Dynamic Data SqlCatalogProvider
Always seeking an elegant solution.
nbrglobalinc
Member
25 Points
98 Posts
Re: Help w/ Small Business Kit and DD
Mar 09, 2009 02:59 AM|LINK
All right, cool, think I've found a way around the SqlCatalogProvider problem but now I get a Error 1 Too many arguments to 'Public Sub New()'. from:
While r.Read()
If TypeOf r("id") Is DBNull Or TypeOf r("visible") Is DBNull Or TypeOf r("title") Is DBNull Then
Throw New InvalidOperationException(Messages.ItemRequiredAttributesMissing)
End If
curr = New Item(CStr(r("id")), CType(r("visible"), [Boolean]), CStr(r("title")))
curr.Description = Util.ReturnEmptyStringIfDbNull(r("description"))
curr.NavigateUrl = Util.ReturnEmptyStringIfDbNull(r("navigateUrl"))
curr.ImageUrl = Util.ReturnEmptyStringIfDbNull(r("imageUrl"))
curr.ImageAltText = Util.ReturnEmptyStringIfDbNull(r("imageAltText"))
list.Add(curr)
End While
sjnaughton
All-Star
27308 Points
5458 Posts
MVP
Re: Help w/ Small Business Kit and DD
Mar 09, 2009 11:27 AM|LINK
Where's this code from? is it your code or some autogenerated code or from the Linq to SQL model code?
Dynamic Data SqlCatalogProvider
Always seeking an elegant solution.
nbrglobalinc
Member
25 Points
98 Posts
Re: Help w/ Small Business Kit and DD
Mar 09, 2009 07:59 PM|LINK
This code was taken out of the SqlCatalogProvider class.
sjnaughton
All-Star
27308 Points
5458 Posts
MVP
Re: Help w/ Small Business Kit and DD
Mar 09, 2009 08:11 PM|LINK
is that from the Small Business Kit of the DD Classes?
Dynamic Data SqlCatalogProvider
Always seeking an elegant solution.
nbrglobalinc
Member
25 Points
98 Posts
Re: Help w/ Small Business Kit and DD
Mar 09, 2009 08:20 PM|LINK
Yes, that is from the Small Business Kit. If I was able to attach my classes, I would definitely do that. My dbml has quite some code in it.
sjnaughton
All-Star
27308 Points
5458 Posts
MVP
Re: Help w/ Small Business Kit and DD
Mar 09, 2009 10:35 PM|LINK
I think you may be able to put your business logic into an partial class for your dbml file, but that's not a trivial excecise.
Dynamic Data Business Logic SqlCatalogProvider
Always seeking an elegant solution.
nbrglobalinc
Member
25 Points
98 Posts
Re: Help w/ Small Business Kit and DD
Mar 10, 2009 01:12 AM|LINK
All right, after a couple days of tweaking and deleting several classes, I think I have found the problem, which to me seems to be the easiest after all the coding I did. When you move the tables and SPROCs from the SQL database into the Data.dbml, it will automatically take the id, visible, title, etc. so you can go ahead and delete the Item.vb(cs) class and the Category.vb(cs) class since the variables are declared in the data.dbml designer. Now in the Catalog.vb(cs), CatalogProvider.vb(cs), and SqlCatalogProvider.vb(cs) classes, I added an Import DataContext. The DataContext is found in the .dbml class file as part of the partial public class. And just to be on the safe side, I added it to the Messages, DataProvidersSection, ProviderSettingsValidation, and Util classes. And for the Items.aspx behind code, I also added the Import DataContext. When I go to run, it all works! :) [Yes]. So now instead of manually typing everything into an Xml file, I can just add it through Dynamic Data into my tables. Thanks to everyone for looking and responding!
ricka6
All-Star
15070 Points
2272 Posts
Microsoft
Moderator
Re: Help w/ Small Business Kit and DD
Mar 10, 2009 01:26 AM|LINK
Great job! Thanks for posting your results.