#region License
// Copyright 2005-2019 Paul Kohler (https://github.com/paulkohler/minisqlquery). All rights reserved.
// This source code is made available under the terms of the GNU Lesser General Public License v3.0
// https://github.com/paulkohler/minisqlquery/blob/master/LICENSE
#endregion
using MiniSqlQuery.Core.DbModel;
namespace MiniSqlQuery.Core
{
///
/// Creates instance to provide a simplified view of the database schema.
///
public class DatabaseMetaDataService
{
///
/// Creates a schema service for a database depending on the .
/// Currently has specific providers for MSSQL, MSSQL CE and OLE DB.
/// The is the fallback option.
///
/// The provider name, e.g. "System.Data.SqlClient".
///
/// A schema serivce for the based on the .
/// The default is .
///
public static IDatabaseSchemaService Create(string providerName)
{
switch (providerName)
{
case "System.Data.OleDb":
return new OleDbSchemaService { ProviderName = providerName };
case "System.Data.SqlClient":
return new SqlClientSchemaService { ProviderName = providerName };
case "Oracle.DataAccess.Client":
return new OracleSchemaService { ProviderName = providerName };
default:
// The SQL CE types tend to include the version number within the provider name, hence "StartsWith"
if (providerName.StartsWith("System.Data.SqlServerCe."))
{
return new SqlCeSchemaService { ProviderName = providerName };
}
return new GenericSchemaService { ProviderName = providerName };
}
}
}
}