|
From: <fab...@us...> - 2009-03-18 13:41:57
|
Revision: 4145
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4145&view=rev
Author: fabiomaulo
Date: 2009-03-18 13:41:14 +0000 (Wed, 18 Mar 2009)
Log Message:
-----------
Fix NH-1708 (Schema metadata for MsSQL ce) by Sushant Khurana
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Dialect/MsSqlCeDialect.cs
trunk/nhibernate/src/NHibernate/NHibernate.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate/Dialect/Schema/MsSqlCeMetaData.cs
Modified: trunk/nhibernate/src/NHibernate/Dialect/MsSqlCeDialect.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Dialect/MsSqlCeDialect.cs 2009-03-18 13:30:33 UTC (rev 4144)
+++ trunk/nhibernate/src/NHibernate/Dialect/MsSqlCeDialect.cs 2009-03-18 13:41:14 UTC (rev 4145)
@@ -1,6 +1,6 @@
-using System;
using System.Data;
-using NHibernate.SqlCommand;
+using System.Data.Common;
+using NHibernate.Dialect.Schema;
using Environment=NHibernate.Cfg.Environment;
namespace NHibernate.Dialect
@@ -92,5 +92,10 @@
{
get { return false; }
}
+
+ public override IDataBaseSchema GetDataBaseSchema(DbConnection connection)
+ {
+ return new MsSqlCeDataBaseSchema(connection);
+ }
}
}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate/Dialect/Schema/MsSqlCeMetaData.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Dialect/Schema/MsSqlCeMetaData.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Dialect/Schema/MsSqlCeMetaData.cs 2009-03-18 13:41:14 UTC (rev 4145)
@@ -0,0 +1,96 @@
+using System;
+using System.Data;
+using System.Data.Common;
+
+namespace NHibernate.Dialect.Schema
+{
+ public class MsSqlCeDataBaseSchema: AbstractDataBaseSchema
+ {
+ public MsSqlCeDataBaseSchema(DbConnection connection) : base(connection) {}
+
+ public override ITableMetadata GetTableMetadata(DataRow rs, bool extras)
+ {
+ return new MsSqlCeTableMetadata(rs, this, extras);
+ }
+ }
+
+ public class MsSqlCeTableMetadata: AbstractTableMetadata
+ {
+ public MsSqlCeTableMetadata(DataRow rs, IDataBaseSchema meta, bool extras) : base(rs, meta, extras) { }
+
+ protected override void ParseTableInfo(DataRow rs)
+ {
+ Catalog = Convert.ToString(rs["TABLE_CATALOG"]);
+ Schema = Convert.ToString(rs["TABLE_SCHEMA"]);
+ if (string.IsNullOrEmpty(Catalog)) Catalog = null;
+ if (string.IsNullOrEmpty(Schema)) Schema = null;
+ Name = Convert.ToString(rs["TABLE_NAME"]);
+ }
+
+ protected override string GetConstraintName(DataRow rs)
+ {
+ return Convert.ToString(rs["CONSTRAINT_NAME"]);
+ }
+
+ protected override string GetColumnName(DataRow rs)
+ {
+ return Convert.ToString(rs["COLUMN_NAME"]);
+ }
+
+ protected override string GetIndexName(DataRow rs)
+ {
+ return Convert.ToString(rs["INDEX_NAME"]);
+ }
+
+ protected override IColumnMetadata GetColumnMetadata(DataRow rs)
+ {
+ return new MsSqlCeColumnMetadata(rs);
+ }
+
+ protected override IForeignKeyMetadata GetForeignKeyMetadata(DataRow rs)
+ {
+ return new MsSqlCeForeignKeyMetadata(rs);
+ }
+
+ protected override IIndexMetadata GetIndexMetadata(DataRow rs)
+ {
+ return new MsSqlCeIndexMetadata(rs);
+ }
+ }
+
+ public class MsSqlCeColumnMetadata : AbstractColumnMetaData
+ {
+ public MsSqlCeColumnMetadata(DataRow rs) : base(rs)
+ {
+ Name = Convert.ToString(rs["COLUMN_NAME"]);
+
+ object aValue = rs["CHARACTER_MAXIMUM_LENGTH"];
+ if (aValue != DBNull.Value)
+ ColumnSize = Convert.ToInt32(aValue);
+
+ aValue = rs["NUMERIC_PRECISION"];
+ if (aValue != DBNull.Value)
+ NumericalPrecision = Convert.ToInt32(aValue);
+
+ Nullable = Convert.ToString(rs["IS_NULLABLE"]);
+ TypeName = Convert.ToString(rs["DATA_TYPE"]);
+ }
+ }
+
+ public class MsSqlCeIndexMetadata: AbstractIndexMetadata
+ {
+ public MsSqlCeIndexMetadata(DataRow rs) : base(rs)
+ {
+ Name = Convert.ToString(rs["INDEX_NAME"]);
+ }
+ }
+
+ public class MsSqlCeForeignKeyMetadata : AbstractForeignKeyMetadata
+ {
+ public MsSqlCeForeignKeyMetadata(DataRow rs)
+ : base(rs)
+ {
+ Name = Convert.ToString(rs["CONSTRAINT_NAME"]);
+ }
+ }
+}
Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-03-18 13:30:33 UTC (rev 4144)
+++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-03-18 13:41:14 UTC (rev 4145)
@@ -454,6 +454,7 @@
<Compile Include="Dialect\Oracle8iDialect.cs" />
<Compile Include="Dialect\Oracle9iDialect.cs" />
<Compile Include="Dialect\OracleLiteDialect.cs" />
+ <Compile Include="Dialect\Schema\MsSqlCeMetaData.cs" />
<Compile Include="Dialect\Schema\MySQLMetaData.cs" />
<Compile Include="Dialect\Schema\SQLiteMetaData.cs" />
<Compile Include="Dialect\Schema\SybaseAnywhereMetaData.cs" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|