-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathProgram.cs
68 lines (55 loc) · 1.96 KB
/
Program.cs
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
56
57
58
59
60
61
62
63
64
65
66
67
68
using OrigoDB.Core;
using System;
namespace OrigoDb.Examples.GettingStarted
{
class Program
{
static void Main(string[] args)
{
// Start your engines!
// uses current working directory
Engine<BookmarkModel> engine = Engine.LoadOrCreate<BookmarkModel>();
//create and execute some commands
var cmd = new SaveBookmarkCommand(
"http://google.com/",
"Google",
DateTime.Now,
new []{"rich", "ugly", "evil"});
engine.Execute(cmd);
cmd = new SaveBookmarkCommand(
"http://microsoft.com",
"Microsoft",
DateTime.Now,
new[]{"rich", "good"}
);
engine.Execute(cmd);
cmd = new SaveBookmarkCommand(
"http://oracle.com",
"Oracle",
DateTime.Now,
new[] { "rich", "bad", "evil" }
);
engine.Execute(cmd);
//Execute an ad-hoc lambda query
Console.WriteLine("Result of db => db.GetBookmarksByTag(\"evil\")");
var bookmarks = engine.Execute((BookmarkModel db) => db.GetBookmarksByTag("evil"));
foreach (var bookmark in bookmarks)
{
Console.WriteLine(bookmark.Title);
Console.WriteLine(bookmark.Url);
}
Console.WriteLine("---");
//Execute a strongly typed query
Console.WriteLine("Result of GetBookmarksPagedQuery(0,2)");
var query = new GetBookmarksPagedQuery(0, 2);
var page = engine.Execute(query);
foreach (var bookmark in page)
{
Console.WriteLine(bookmark.Title);
Console.WriteLine(bookmark.Url);
}
Console.WriteLine("hit return to terminate");
Console.ReadLine();
}
}
}