DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
Public Member Functions | List of all members
Deveel.Data.QueryTest Class Reference
Inheritance diagram for Deveel.Data.QueryTest:

Public Member Functions

void CountPeople ()
 
void AvgAge ()
 
void PeopleInAfrica ()
 
void OasisOrBeatles ()
 
void ListIdentities ()
 

Detailed Description

Definition at line 30 of file QueryTest.cs.

Member Function Documentation

void Deveel.Data.QueryTest.AvgAge ( )
inline

Definition at line 47 of file QueryTest.cs.

47  {
48  Console.Out.WriteLine("Computing the average ages of people in 'Person' table...");
49 
50  IDbCommand command = Connection.CreateCommand();
51  command.CommandText = "SELECT AVG(age) FROM Person";
52  IDataReader reader = command.ExecuteReader();
53 
54  if (reader.Read())
55  Console.Out.WriteLine("Average age of people: {0}", reader.GetDouble(0));
56 
57  reader.Close();
58  }
void Deveel.Data.QueryTest.CountPeople ( )
inline

Definition at line 32 of file QueryTest.cs.

32  {
33  Console.Out.WriteLine("Counting the number of rows in 'Person' table...");
34 
35  // Create a Statement object to execute the queries on,
36  IDbCommand statement = Connection.CreateCommand();
37 
38  // How many rows are in the 'Person' table?
39  statement.CommandText = "SELECT COUNT(*) FROM Person";
40  IDataReader result = statement.ExecuteReader();
41  if (result.Read()) {
42  Console.Out.WriteLine("Rows in 'Person' table: " + result.GetInt32(0));
43  }
44  }
void Deveel.Data.QueryTest.ListIdentities ( )
inline

Definition at line 97 of file QueryTest.cs.

97  {
98  IDbCommand command = Connection.CreateCommand();
99  command.CommandText = "SELECT IDENTITY FROM Person";
100 
101  using (IDataReader reader = command.ExecuteReader()) {
102  if (reader.Read())
103  Console.Out.WriteLine("The latest identity for the table Person : {0}", reader.GetInt32(0));
104  }
105  }
void Deveel.Data.QueryTest.OasisOrBeatles ( )
inline

Definition at line 76 of file QueryTest.cs.

76  {
77  // List the name and music group of all the people that listen to
78  // either 'Oasis' or 'Beatles'
79  IDbCommand command = Connection.CreateCommand();
80  command.CommandText = " SELECT Person.name, MusicGroup.name " +
81  " FROM Person, ListensTo, MusicGroup " +
82  " WHERE MusicGroup.name IN ( 'Oasis', 'Beatles' ) " +
83  " AND Person.name = ListensTo.person_name " +
84  " AND ListensTo.music_group_name = MusicGroup.name " +
85  " ORDER BY MusicGroup.name, Person.name ";
86  IDataReader result = command.ExecuteReader();
87  Console.Out.WriteLine("All people that listen to either Beatles or Oasis:");
88  while (result.Read()) {
89  Console.Out.Write(" " + result.GetString(0));
90  Console.Out.Write(" listens to ");
91  Console.Out.WriteLine(result.GetString(1));
92  }
93  Console.Out.WriteLine();
94  }
void Deveel.Data.QueryTest.PeopleInAfrica ( )
inline

Definition at line 61 of file QueryTest.cs.

61  {
62  Console.Out.WriteLine("Selecting all the people in 'Person' table who live in Africa...");
63 
64  IDbCommand command = Connection.CreateCommand();
65  command.CommandText = "SELECT name FROM Person WHERE lives_in = 'Africa' ORDER BY name";
66 
67  IDataReader reader = command.ExecuteReader();
68  Console.Out.WriteLine("All people that live in Africa:");
69  while (reader.Read()) {
70  Console.Out.WriteLine(" " + reader.GetString(0));
71  }
72  Console.Out.WriteLine();
73  }

The documentation for this class was generated from the following file: