[RESOLVED] [2005] Database->?->LINQ->XML
To cut to the point, I will have to use "LINQ to XML" to make an XML document, and the data I will use will come from a database. But the assignment says nothing about how to get the data from the database.
Is there any ASP.NET natural way to pull this off as you see it? Is it maybe possible to pragmatically pull data out of a object datasource maybe? Or would that be like jumping over the fence to fetch something that is already in your back yard?
- ØØ -
Re: [2005] Database->?->LINQ->XML
Well you can connect to a database and run queries all from LINQ. check out this guide from MS: http://msdn2.microsoft.com/en-us/library/bb425822.aspx
Re: [2005] Database->?->LINQ->XML
Thanks, but I see this document is written for .NET 3.5. Was this even implemented in VS 2005?
- ØØ -
Re: [2005] Database->?->LINQ->XML
Quote:
Originally Posted by NoteMe
Thanks, but I see this document is written for .NET 3.5. Was this even implemented in VS 2005?
- ØØ -
Well you posted stated you were using 2005 but LINQ is only in 2008 and you had said you wanted to use LINQ to Xml so I assumed you put the wrong version.
Yeah, if you want to use LINQ then you have to have 2008. If you're just looking for a way to get data from a database then you can use the built in .Net classes or try out the Enterprise Library Blocks from Microsoft which makes database access a breeze.
Re: [2005] Database->?->LINQ->XML
Create your 'entity' class to mirror what's in your table set, make sure it inherits from DataContext, then use your LINQ on it. Because you can then shape the data, you can create a new XDocument, XMLDocument, whatever you want as the 'returned' item from the query. Then save it.
Re: [2005] Database->?->LINQ->XML
Quote:
Well you posted stated you were using 2005 but LINQ is only in 2008 and you had said you wanted to use LINQ to Xml so I assumed you put the wrong version.
No I ment 2005, and I ment LINQ. Maybe not in production environments, but for Uni using LINQ in 2005 works well using the May 2006 CTP.
Quote:
Create your 'entity' class to mirror what's in your table set, make sure it inherits from DataContext, then use your LINQ on it. Because you can then shape the data, you can create a new XDocument, XMLDocument, whatever you want as the 'returned' item from the query. Then save it.
I would never have figguered out the save part my self :p No really, cheers. Believe it or not, I got it working. So it seems I managed the whole semester while working 100% in 3months + :p Wooohooo. No I will use the rest of the year reading poetry :)
Cheers,
- ØØ -
Re: [RESOLVED] [2005] Database->?->LINQ->XML
Mind sharing some code then?
Let's see what you've done. Unless it's highly confidential.