3 using MySql
.Data
.MySqlClient
;
7 public static void Main(string[] args
)
9 string connectionString
= "Server=localhost;Database=test;User ID=root;Password=;";
10 IDbConnection conn
= new MySqlConnection(connectionString
);
13 sqlgg
.all gen
= new sqlgg
.all(conn
);
15 gen
.drop_person
.execute();
16 gen
.drop_money
.execute();
18 gen
.create_person
.execute();
19 gen
.create_money
.execute();
21 IDbCommand last_id
= conn
.CreateCommand();
22 last_id
.CommandText
= "SELECT LAST_INSERT_ID()";
25 gen
.add_person
.execute("John","Black");
26 long john
= (long)last_id
.ExecuteScalar();
28 gen
.add_person
.execute("Ivan","Petrov");
29 long ivan
= (long)last_id
.ExecuteScalar();
31 gen
.add_person
.execute("Sancho","Alvares");
32 long sancho
= (long)last_id
.ExecuteScalar();
34 // add money relations
35 gen
.add_money
.execute(john
,ivan
,200);
36 gen
.add_money
.execute(john
,sancho
,100);
37 gen
.add_money
.execute(john
,sancho
,250);
38 gen
.add_money
.execute(sancho
,ivan
,300);
40 Console
.WriteLine("Total transfers:");
41 foreach (var row
in gen
.calc_total
.rows())
43 Console
.WriteLine(row
.fullname
+ " = " + row
.total
);
46 Console
.WriteLine("Donors:");
47 gen
.list_donors
.execute("petrov",100,delegate(string surname
) { Console.WriteLine(surname); }
);