-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAureliusSimples.dpr
More file actions
61 lines (49 loc) · 1.41 KB
/
AureliusSimples.dpr
File metadata and controls
61 lines (49 loc) · 1.41 KB
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
program AureliusSimples;
{$APPTYPE CONSOLE}
{$R *.res}
uses
System.SysUtils,
Aurelius.Drivers.MSSQL,
Aurelius.Drivers.Interfaces,
Aurelius.Engine.ObjectManager,
uAluno in 'uAluno.pas',
System.Generics.Collections, Aurelius.Criteria.Base, Aurelius.Criteria.Linq;
var
MyConnection: IDBConnection;
Manager: TObjectManager;
Aluno: TAluno;
Alunos: TList<TAluno>;
begin
try
MyConnection := TMSSQLConnection.Create('Server=.\SQLEXPRESS;Database=HibernateTest;TrustedConnection=True');
Manager := TObjectManager.Create(MyConnection);
Aluno := Manager.Find<TAluno>(2);
Writeln(Aluno.Nome);
Writeln(Aluno.Nota);
Writeln(Aluno.Matricula);
Aluno.Nota := 7;
Aluno.Matricula := '123456';
Manager.Flush; //all objects
Aluno := TAluno.Create('Fabiano');
Aluno.Nota := 9.5;
Aluno.Matricula := '111';
Manager.Save(Aluno);
Alunos := Manager.Find<TAluno>.List;
//Alunos := Manager.Find<TAluno>.Take(2).OrderBy('Nome').List;
Writeln('Manager.Find<TAluno>.List');
for Aluno in Alunos do
Writeln(Aluno.Nome);
Alunos := Manager.Find<TAluno>.Where
(
Linq['Nome'].Like('%Fer%')
or Linq['Nome'].Like('%Fab%')
).List;
Writeln('--------------- Manager.Find<TAluno>.Where.List');
for Aluno in Alunos do
Writeln(Aluno.Nome);
Readln;
except
on E: Exception do
Writeln(E.ClassName, ': ', E.Message);
end;
end.