rmagruder (2) [Avatar] Offline
#1
Having read this book and done some fruitless google searches, one thing I don't really see covered is how to easily switch between a SQL data source and an XML Data Source, such as if I were doing a small 'briefcase' or prototype application, vs going live against a Database server.

What's the minimum I would have to change? And what can I do to make a single code base support multiple/switchable mappings?

Randy
jwooley (123) [Avatar] Offline
#2
Re: Transparently switching between XML and SQL..?
LINQ doesn't really do much for you here. However, if you are looking to do partially connected applications, you may want to consider using Sql Server compact (SSCE) for your local store and Sync services to replicate that with your database. You can use LINQ to SQL and LINQ to Entities to work against SSCE. Realize the the LINQ to SQL designer does not work against SSCE, so you would need to manage your mappings manually or use SQL Metal (see chapter 7).

For a prototype, if you use SQL Express for prototyping, you can up-size that to full SQL Server when going live without changes to your application (other than the config file of course).

Jim
rmagruder (2) [Avatar] Offline
#3
Re: Transparently switching between XML and SQL..?
Darn I was really hoping that I could leverage the same LINQ queries against both SQL and XML smilie
jwooley (123) [Avatar] Offline
#4
Re: Transparently switching between XML and SQL..?
LINQ to SQL and LINQ to Object queries are quite similar. LINQ to XML is a bit different in so much as the XML Axes methods (Elements/Attributes/Descendts) are regarded. There isn't a correlary to those methods in the LINQ to SQL space.

What I think you are looking for isn't so much the query functionality, but the updating functionality (to move data between platforms). Each platform has separate mechanisms for persistance and as such isn't a LINQ feature per-sey. ADO.Net Data Services leverages IUpdateable which the Entity Framework implements. If you were to implement that against your LINQ to SQL and LINQ to XML constructs, you might be able to interop between them. This is definately NOT something that comes out of the box however.

Jim