This question is locked. New answers and comments are not allowed.
I am surprised at the small number of articles that cover how to export data from an sql database to an xml file using linq.
I found the site Hooked on Linq which was very useful, but have now come up with an error that i can not get around.
The example on this site uses the format: (in C#)
Here is my code: (in VB)
Dim scope As IObjectScope = BlogLinkVB.ObjectScopeProvider1.GetNewObjectScope()
Dim xml As XElement = New XElement("urlset", _
From p In scope.Extent(Of BlogLinkVB.Category)() _
Select New XElement("url", _
New XElement("loc", p.Name), _
New XElement("lastmod", customdate), _
New XElement("changefreq", "daily"), _
New XElement("priority", "0.50")))
As you might notice I am trying to create a Google Sitemap from data I have stored in my database, the tags from blogposts.
The error message I am getting is:
Exception Details: System.InvalidCastException: Unable to cast object of type 'System.Linq.Expressions.NewArrayExpression' to type 'OpenAccessRuntime.DataObjects.query.Node'.
Source Error:
Any thoughts would be appreciated. My other calls in Linq are working ok and the scope.Extent() intellisense tooltip confirms that this is an IQueryable instance.
When this is working it might make a very useful example for the OpenAccess demos page. Dynamic creation of xml from databases is very useful as is being able to make a rapid fire sitemap for google or yahoo and keep it easily updated.
Thanks
Alan
I found the site Hooked on Linq which was very useful, but have now come up with an error that i can not get around.
The example on this site uses the format: (in C#)
XElement xml = new XElement("contacts", from c in db.Contacts orderby c.ContactId select new XElement("contact", new XAttribute("contactId", c.ContactId), new XElement("firstName", c.FirstName), new XElement("lastName", c.LastName)) );
Here is my code: (in VB)
Dim scope As IObjectScope = BlogLinkVB.ObjectScopeProvider1.GetNewObjectScope()
Dim xml As XElement = New XElement("urlset", _
From p In scope.Extent(Of BlogLinkVB.Category)() _
Select New XElement("url", _
New XElement("loc", p.Name), _
New XElement("lastmod", customdate), _
New XElement("changefreq", "daily"), _
New XElement("priority", "0.50")))
As you might notice I am trying to create a Google Sitemap from data I have stored in my database, the tags from blogposts.
The error message I am getting is:
Unable to cast object of type 'System.Linq.Expressions.NewArrayExpression' to type 'OpenAccessRuntime.DataObjects.query.Node'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.Exception Details: System.InvalidCastException: Unable to cast object of type 'System.Linq.Expressions.NewArrayExpression' to type 'OpenAccessRuntime.DataObjects.query.Node'.
Source Error:
Line 48: 'Next
Line 49:
Line 50: Dim xml As XElement = New XElement("urlset", _
Line 51: From p In scope.Extent(Of BlogLinkVB.Category)() _
Line 52: Select New XElement("url", _
|
Any thoughts would be appreciated. My other calls in Linq are working ok and the scope.Extent() intellisense tooltip confirms that this is an IQueryable instance.
When this is working it might make a very useful example for the OpenAccess demos page. Dynamic creation of xml from databases is very useful as is being able to make a rapid fire sitemap for google or yahoo and keep it easily updated.
Thanks
Alan