Skip to content

Instantly share code, notes, and snippets.

@rofr
Last active August 29, 2015 13:57
Show Gist options
  • Select an option

  • Save rofr/9684919 to your computer and use it in GitHub Desktop.

Select an option

Save rofr/9684919 to your computer and use it in GitHub Desktop.
More scriptcs and origodb awesomeness!
rofr@DELLCRAPPO /c/git/scriptcs/origo1
$ scriptcs
scriptcs (ctrl-c to exit)
> using OrigoDB.Core;
> #r Todo.Core.dll
> using Todo.Core;
> var engine = Engine.Load<TodoModel>();
> using OrigoDB.Core.Proxy;
> var db = engine.GetProxy();
> db
{
"$id": "1",
"Lists": [
{
"$id": "2",
"Name": "backlog",
"Tasks": [
{
"$id": "3",
"Id": "b27f8b11-edfe-483d-a8ba-71ae1a5a0055",
"Title": "shave",
"Description": null,
"DueBy": "2014-03-21T12:57:12.9102045+01:00",
"Completed": null,
"Categories": []
},
{
"$id": "4",
"Id": "45c2a1d7-8e2b-4832-8f8b-f0ce89fe48da",
"Title": "Pack squashgear",
"Description": null,
"DueBy": null,
"Completed": null,
"Categories": [
{
"$id": "5",
"Name": "Travel",
"Tasks": [
{
"$ref": "4"
}
]
}
]
}
]
},
{
"$id": "6",
"Name": "completed",
"Tasks": []
}
],
"Categories": []
}
> var task = new Task("Experiment with scriptcs");
> task
{
"$id": "1",
"Id": "42c095df-429c-4516-9825-9eb4db81a71e",
"Title": "Experiment with scriptcs",
"Description": null,
"DueBy": null,
"Completed": null,
"Categories": []
}
> engine.Execute(new AddTaskCommand(task, "completed"));
> db
{
"$id": "1",
"Lists": [
{
"$id": "2",
"Name": "backlog",
"Tasks": [
{
"$id": "3",
"Id": "b27f8b11-edfe-483d-a8ba-71ae1a5a0055",
"Title": "shave",
"Description": null,
"DueBy": "2014-03-21T12:57:12.9102045+01:00",
"Completed": null,
"Categories": []
},
{
"$id": "4",
"Id": "45c2a1d7-8e2b-4832-8f8b-f0ce89fe48da",
"Title": "Pack squashgear",
"Description": null,
"DueBy": null,
"Completed": null,
"Categories": [
{
"$id": "5",
"Name": "Travel",
"Tasks": [
{
"$ref": "4"
}
]
}
]
}
]
},
{
"$id": "6",
"Name": "completed",
"Tasks": [
{
"$id": "7",
"Id": "42c095df-429c-4516-9825-9eb4db81a71e",
"Title": "Experiment with scriptcs",
"Description": null,
"DueBy": null,
"Completed": null,
"Categories": []
}
]
}
],
"Categories": []
}
> engine.CreateSnapshot();
2014-03-21 13:07:20 - INFO - OrigoDB.Core.Kernel - BeginSnapshot:2
2014-03-21 13:07:20 - INFO - OrigoDB.Core.Kernel - EndSnapshot:2
> db.Lists.SelectMany(list => list.Tasks)
[
{
"$id": "1",
"Id": "b27f8b11-edfe-483d-a8ba-71ae1a5a0055",
"Title": "shave",
"Description": null,
"DueBy": "2014-03-21T12:57:12.9102045+01:00",
"Completed": null,
"Categories": []
},
{
"$id": "2",
"Id": "45c2a1d7-8e2b-4832-8f8b-f0ce89fe48da",
"Title": "Pack squashgear",
"Description": null,
"DueBy": null,
"Completed": null,
"Categories": [
{
"$id": "3",
"Name": "Travel",
"Tasks": [
{
"$ref": "2"
}
]
}
]
},
{
"$id": "4",
"Id": "42c095df-429c-4516-9825-9eb4db81a71e",
"Title": "Experiment with scriptcs",
"Description": null,
"DueBy": null,
"Completed": null,
"Categories": []
}
]
> db.Lists.SelectMany(list => list.Tasks.Title)
(1,40): error CS1061: 'System.Collections.Generic.List<Todo.Core.Task>' does not
contain a definition for 'Title' and no extension method 'Title' accepting a fi
rst argument of type 'System.Collections.Generic.List<Todo.Core.Task>' could be
found (are you missing a using directive or an assembly reference?)
> db.Lists.SelectMany(list => list.Tasks.Name)
(1,40): error CS1061: 'System.Collections.Generic.List<Todo.Core.Task>' does not
contain a definition for 'Name' and no extension method 'Name' accepting a firs
t argument of type 'System.Collections.Generic.List<Todo.Core.Task>' could be fo
und (are you missing a using directive or an assembly reference?)
> db.Lists.SelectMany(list => list.Tasks.Select(task => task.Name))
(1,60): error CS1061: 'Todo.Core.Task' does not contain a definition for 'Name'
and no extension method 'Name' accepting a first argument of type 'Todo.Core.Tas
k' could be found (are you missing a using directive or an assembly reference?)
> db.Lists.SelectMany(list => list.Tasks.Select(task => task.Title))
[
"shave",
"Pack squashgear",
"Experiment with scriptcs"
]
>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment