#develop (short for SharpDevelop) is a free IDE for .NET programming languages.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

85 lines
2.4 KiB

// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Dickon Field" email=""/>
// <version>$Revision$</version>
// </file>
/*
* User: Dickon Field
* Date: 10/07/2006
* Time: 09:12
*
*/
using System;
using System.Data;
using System.Data.Common;
using System.Collections.Generic;
namespace SharpDbTools.Model
{
/// <summary>
/// DbModel is a DataSet containing the metadata tables returned from a DbConnection.
/// It adds methods designed specifically to facilitate access to the data in the
/// DataTables contained by the DbModel.
///
/// The DbModel class is intended to be usable in a fully disconnected mode - that is,
/// it requires a DbConnection to populate it, but it may then be locally persisted and subsequently
/// retrieved from its persisted data. This is intended to allow work to progress against the
/// DbModel without requiring a connection to its RDB server.
/// </summary>
///
public class DbModelInfo: DataSet
{
public const string METADATACOLLECTIONS = "MetaDataCollections";
public string Name {
get {
DataTable table = this.Tables[TableNames.ConnectionInfo];
string name = (string)table.Rows[0][ColumnNames.Name];
return name;
}
}
public string InvariantName {
get {
DataTable table = this.Tables[TableNames.ConnectionInfo];
string invariantName = (string)table.Rows[0][ColumnNames.InvariantName];
return invariantName;
}
}
public string ConnectionString {
get {
DataTable table = this.Tables[TableNames.ConnectionInfo];
string connectionString = (string)table.Rows[0][ColumnNames.InvariantName];
return connectionString;
}
}
public DbModelInfo(string name, string invariantName, string connectionString)
{
// create a table in the DbModelInfo to hold this initial info.
// this creates a consistent representation of the data and makes
// it easier to serialise it
DataTable table = this.Tables.Add("Connection");
table.Columns.Add("name", typeof(string));
table.Columns.Add("invariantName", typeof(string));
table.Columns.Add("connectionString", typeof(string));
}
public DataTable MetaDataCollections {
get {
return this.Tables[METADATACOLLECTIONS];
}
}
public DataTable this[string collectionName] {
get {
return this.Tables[collectionName];
}
}
}
}