Skip to content

Commit

Permalink
Fixed SqlCe40SchemaProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
markrendle committed Jan 20, 2011
1 parent babb219 commit 094192c
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions Simple.Data.SqlCe40/SqlCe40SchemaProvider.cs
Expand Up @@ -37,8 +37,10 @@ private static Table SchemaRowToTable(DataRow row)

public IEnumerable<Column> GetColumns(Table table)
{
if (table == null) throw new ArgumentNullException("table");
return GetColumnsDataTable(table).AsEnumerable().Select(row => SchemaRowToColumn(table, row));
foreach (var row in GetColumnsDataTable(table).AsEnumerable())
{
yield return new Column(row["COLUMN_NAME"].ToString(), table);
}
}

private static Column SchemaRowToColumn(Table table, DataRow row)
Expand Down Expand Up @@ -134,11 +136,7 @@ public Type DataTypeToClrType(string dataType)

private DataTable GetColumnsDataTable(Table table)
{
var columnSelect =
string.Format(
"SELECT name, is_identity from sys.columns where object_id = object_id('{0}.{1}', 'TABLE')",
table.Schema, table.ActualName);
return SelectToDataTable(columnSelect);
return SelectToDataTable("SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '" + table.ActualName + "'");
}

private DataTable GetPrimaryKeys()
Expand Down

0 comments on commit 094192c

Please sign in to comment.