improvedk / OrcaMDF

A C# parser for MDF files. Allows you to read tables, metadata and indexes from MDF files without it being attached to a running SQL Server instance.
http://improve.dk/archive/2011/05/03/introducing-orcamdf.aspx
GNU General Public License v3.0
181 stars 74 forks source link

reading sysschobjs does not return rows #34

Open cmhapan opened 6 years ago

cmhapan commented 6 years ago

I am trying to read the sysschobjs table using rawdatabase. Using the sample code from http://improve.dk/orcamdf-rawdatabase-a-swiss-army-knife-for-mdf-files.

**var db = new RawDataFile(@"c:\temp\temp.mdf"); var records = db.Pages .Where(x => x.Header.ObjectID == 34 && x.Header.Type == PageType.Data) .SelectMany(x => x.Records);

        var rows =  records.Select(x => RawColumnParser.Parse((RawPrimaryRecord)x, new IRawType[] {
                  RawType.Int("id"),
                      RawType.NVarchar("name")
                        }));
         rows.Select(x => x["name"]).Dump();**

I had to use RawDataFile because RawDataBase was not in the code I downloaded from github.

All I get from the Dump command is this:

System.Linq.Enumerable+WhereSelectEnumerableIterator`2[OrcaMDF.RawCore.Records.RawRecord,System.Object]

I added this code to see how many records and rows were returned:

row_count = rows.Count(); record_count = records.Count(); Console.WriteLine($"Rows count = {row_count}"); Console.WriteLine($"Records count = {record_count}");

and it shows this:

Rows count = 4327 Records count = 4327