The Enterprise Library will allow you to use different databases as long as
you stick with the common objects in your code. I have never used .NET to
query an XML file so that I'm a little unsure about.
As for using it with different databases here are some tips:
Don't use SqlDataReader or other similar objects in your data layer when
querying the databases. Also, I would suggest using stored procedures when
querying data out of your database since SQL syntax may differ from server
to server.
Here's a very simple example how to ensure querying data out of the database
will keep the type of database transparent:
using Microsoft.Practices.EnterpriseLibrary.Data;
using System;
using System.Data;
using System.Data.Common;
Database db = DatabaseFactory.Create(); // You may need to specify the name
of a connection string here if you're using multiples.
using (DbCommand cmd = db.GetStoredProcedure("MyProcedureName")) {
cmd.Parameters.Add("@myparam", DbType.Int32, 123);
using (IDataReader reader = db.ExecuteReader(cmd)) {
while (reader.Read()) {
// Do what you want with the data retrieved.
}
}
}
Also, if you're looking for a simpler data layer and do not need access to
the rest of the functionality provided by the Enterprise Library you may
want to research LINQ to SQL or NHibernate though again, I'm not sure if
either of those can query XML files either.