forked from improvedk/OrcaMDF
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Adhoc.linq
55 lines (48 loc) · 1.47 KB
/
Adhoc.linq
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<Query Kind="Statements">
<Output>DataGrids</Output>
<Reference Relative="src\OrcaMDF.RawCore\bin\Debug\OrcaMDF.RawCore.dll">D:\Projects\OrcaMDF (GIT)\src\OrcaMDF.RawCore\bin\Debug\OrcaMDF.RawCore.dll</Reference>
<Namespace>OrcaMDF.RawCore</Namespace>
<Namespace>OrcaMDF.RawCore.Records</Namespace>
</Query>
// Get single data page
var db = new RawDatabase(@"C:\AW2008R2.mdf");
db.GetPage(1, 5000).Dump();
// Get single index page
var db = new RawDatabase(@"C:\AW2008R2.mdf");
db.GetPage(1, 77).Dump();
// Get all distinct types of pages
var db = new RawDatabase(@"C:\AW2008R2.mdf");
db.Pages
.Select(x => x.Header.Type)
.Distinct()
.Dump();
// Get all pages of a certain type
var db = new RawDatabase(@"C:\AW2008R2.mdf");
db.Pages
.Where(x => x.Header.Type == PageType.IAM)
.Dump();
// Get all index pages with their slot count
var db = new RawDatabase(@"C:\AW2008R2.mdf");
db.Pages
.Where(x => x.Header.Type == PageType.Index)
.Select(x => new {
x.PageID,
x.Header.SlotCnt
}).Dump();
// Get certain properties of all pages
var db = new RawDatabase(@"C:\AW2008R2.mdf");
db.Pages.Select(x => new {
x.PageID,
x.Header.Type,
x.Header.SlotCnt
}).Dump();
// Predicate search for all pages
var db = new RawDatabase(@"C:\AW2008R2.mdf");
db.Pages
.Where(x => x.Header.FreeData > 7000)
.Where(x => x.Header.SlotCnt >= 1)
.Select(x => new {
x.PageID,
x.Header.FreeData,
RecordCount = x.Records.Count()
}).Dump();