This repository was archived by the owner on Dec 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 611
Expand file tree
/
Copy pathMain.cs
More file actions
107 lines (73 loc) · 2.76 KB
/
Copy pathMain.cs
File metadata and controls
107 lines (73 loc) · 2.76 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
using System;
using System.Linq;
using System.Data;
using System.ComponentModel.DataAnnotations;
using System.Collections.Generic;
using ServiceStack.Common.Utils;
using ServiceStack.DataAnnotations;
using ServiceStack.Common.Extensions;
using ServiceStack.DesignPatterns.Model;
using ServiceStack.OrmLite;
using ServiceStack.OrmLite.Firebird;
using Database.Records;
namespace Database.Records{
public partial class Company{
[Ignore]
public string UpperName{
get { return Name.ToUpper();}
}
}
}
namespace TestLiteFirebird2
{
class MainClass
{
public static void Main (string[] args)
{
//Set one before use (i.e. in a static constructor).
OrmLiteConfig.DialectProvider = new FirebirdOrmLiteDialectProvider();
using (IDbConnection db =
"User=SYSDBA;Password=masterkey;Database=employee.fdb;DataSource=localhost;Dialect=3;charset=ISO8859_1;".OpenDbConnection())
using ( IDbCommand dbConn = db.CreateCommand())
{
try{
Console.WriteLine( dbConn.HasChildren<Company>( new Company(){Id=1000} ) );
Console.WriteLine(dbConn.HasChildren<Company>( new Company(){Id=5} )) ;
Console.WriteLine( dbConn.Exists<Company>( Company.Me.Id+"={0}",5 ) );
Console.WriteLine(dbConn.Exists<Company>( Company.Me.Id+"={0}",1000 )) ;
var rows = dbConn.Select<Company>();
Console.WriteLine("Company: rows before insert :{0}", rows.Count);
Company cp = new Company{
Name="One More Company", Employees=10,
Started= DateTime.Today, Turnover= 12525,
CreatedDate= DateTime.Now
};
dbConn.Insert( cp);
rows = dbConn.Select<Company>();
Console.WriteLine("Company: rows after insert :{0}", rows.Count);
foreach(Company u in rows){
Console.WriteLine("{0} -- {1}" , u.Id, u.Name);
}
Console.WriteLine("----------------------");
rows = dbConn.Select<Company>(Company.Me.Id+">={0} order by " +Company.Me.Id+" descending rows 5",
10);
Console.WriteLine(rows.Count);
foreach(Company u in rows){
Console.WriteLine("{0} -- {1} -- {2} -- {3} -- {4} -- {5} --{6}", u.Id, u.Name,
(u.Employees.HasValue)?u.Employees.Value.ToString():"",
u.Started.HasValue?u.Started.Value.ToString():"",
u.Turnover.HasValue?u.Turnover.Value.ToString():"",
u.CreatedDate.HasValue?u.CreatedDate.Value.ToString():"",
u.UpperName
);
}
}
catch(Exception e){
Console.WriteLine(e);
}
}
}
}
//s.Substring(7, s.IndexOf("FROM")-8) --> columns
//s.Substring( s.IndexOf("FROM")+5)
}