public override IList<PrimaryKey> GetAllPrimaryKeys()
        {
            this.Database.Connection.Open();
            DataTable primaryKeyTable = (this.Database.Connection as OleDbConnection).GetOleDbSchemaTable(
                OleDbSchemaGuid.Primary_Keys, null);
            this.Database.Connection.Close();

            if (primaryKeyTable == null || primaryKeyTable.Rows.Count == 0)
            {
                return new List<PrimaryKey>();
            }

            IList<PrimaryKey> primaryKeys = new List<PrimaryKey>();
            PrimaryKey primaryKey;

            foreach (DataRow row in primaryKeyTable.Rows)
            {
                primaryKey = new PrimaryKey();
                primaryKey.TableName = row["TABLE_NAME"].AsString();
                primaryKey.Key = row["COLUMN_NAME"].AsString(); 
                primaryKeys.Add(primaryKey);
            }

            return primaryKeys;
        }
        public override IList<PrimaryKey> GetAllPrimaryKeys()
        {
            string sql = @"SELECT TableName=T.name,PrimaryKey=C.name FROM syscolumns C INNER JOIN " +
                "sysobjects T ON C.id=T.id and T.xtype='U' AND T.name<>'dtproperties' " +
                "WHERE EXISTS(SELECT 1 FROM sysobjects WHERE xtype='PK' AND name IN( " +
                "SELECT name FROM sysindexes WHERE indid IN( SELECT indid FROM sysindexkeys WHERE id=C.id AND colid=C.colid ))) ORDER BY T.name ";
 

            this.Database.Connection.Open();
            DataTable primaryKeyTable = this.Database.ExecuteDataTable(sql, false);
            this.Database.Connection.Close();

            if (primaryKeyTable == null || primaryKeyTable.Columns.Count <= 0)
            {
                return new List<PrimaryKey>();
            }

            IList<PrimaryKey> primartKeys = new List<PrimaryKey>();
            PrimaryKey primaryKey;

            foreach (DataRow row in primaryKeyTable.Rows)
            {
                primaryKey = new PrimaryKey();
                primaryKey.TableName = row["TableName"].AsString();
                primaryKey.Key = row["PrimaryKey"].AsString();

                primartKeys.Add(primaryKey);
            }

            return primartKeys;
        }
        public override IList<PrimaryKey> GetAllPrimaryKeys()
        {
            string sql = @"select col.table_name TableName,col.column_name PrimaryKey from user_constraints con,  user_cons_columns col " +
                "where con.constraint_name = col.constraint_name and con.constraint_type='P'";

            this.Database.Connection.Open();
            DataTable primaryKeyTable = this.Database.ExecuteDataTable(sql, false);
            this.Database.Connection.Close();
 
                if (primaryKeyTable == null || primaryKeyTable.Columns.Count <= 0)
                {
                    return new List<PrimaryKey>();
                }

            IList<PrimaryKey> primartKeys =new List<PrimaryKey>();
            PrimaryKey primaryKey;

                foreach (DataRow row in primaryKeyTable.Rows)
                {
                    primaryKey =new PrimaryKey();
                    primaryKey.TableName =row["TableName"].AsString();
                    primaryKey.Key =row["PrimaryKey"].AsString();
                   
                    primartKeys.Add(primaryKey);
                }

            return primartKeys;
        }
        public override IList<PrimaryKey> GetAllPrimaryKeys()
        {
            string primarySql = @"SELECT  TABLE_NAME,COLUMN_NAME FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE
                                  WHERE TABLE_SCHEMA='{0}' and CONSTRAINT_NAME='PRIMARY'";

            DataTable primaryTable = GetTable(primarySql);

            if (primaryTable.Rows.Count == 0)
            {
                return new List<PrimaryKey>();
            }

            var primaryKeys = new List<PrimaryKey>();
            PrimaryKey primaryKey;

            foreach (DataRow row in primaryTable.Rows)
            {
                primaryKey = new PrimaryKey();
                primaryKey.TableName = row["TABLE_NAME"].AsString();;
                primaryKey.Key = row["COLUMN_NAME"].AsString(); ;

                primaryKeys.Add(primaryKey);
            }

            return primaryKeys;
        }
        public override IList<PrimaryKey> GetAllPrimaryKeys()
        {
            IEnumerable<TableColumn> tableColumns = GetAllTableColumns();
            IEnumerable<TableColumn> primaryColumns = tableColumns.Where(p => p.IsPrimaryKey);

            if(primaryColumns.Count()==0)
            {
                return new List<PrimaryKey>();
            }

            var primaryKeys = new List<PrimaryKey>();
            PrimaryKey primaryKey;

            foreach(var column in primaryColumns)
            {
                primaryKey=new PrimaryKey();
                primaryKey.TableName = column.TableName;
                primaryKey.Key = column.ColumnName;

                primaryKeys.Add(primaryKey);
            }

            return primaryKeys;
        }