Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace DatabaseTestings
- {
- internal class Program
- {
- private static void Main()
- {
- var testdb = new DataBase();
- testdb.Add("GameName", "Accounts", new Accounts {Username = "KiraNL", Password = "TestPass"});
- testdb.Add("GameName", "Accounts", new Accounts {Username = "MysteryPerson", Password = "MysteryPass"});
- Console.WriteLine("Tables ({0}):", testdb.Tables().Count);
- foreach (string table in testdb.Tables())
- {
- Console.WriteLine(table);
- }
- Console.WriteLine("Rows ({0}):", testdb.Rows().Count);
- foreach (string row in testdb.Rows())
- {
- Console.WriteLine(row);
- }
- Console.WriteLine("Test query for KiraNL:");
- foreach (object row in testdb.GetRow("Accounts"))
- {
- var current = (Accounts) row;
- if (current.Username == "KiraNL")
- {
- Console.WriteLine(current.Username);
- Console.WriteLine(current.Password);
- break;
- }
- }
- Console.WriteLine("Users {0}:", testdb.GetRow("Accounts").Count);
- foreach (object row in testdb.GetRow("Accounts"))
- {
- var current = (Accounts) row;
- Console.WriteLine(current.Username);
- }
- Console.WriteLine("Test remove of KiraNL");
- foreach (object row in testdb.GetRow("Accounts"))
- {
- var current = (Accounts) row;
- if (current.Username == "KiraNL")
- {
- testdb.Remove(current);
- break;
- }
- }
- Console.WriteLine("Users {0}:", testdb.GetRow("Accounts").Count);
- foreach (object row in testdb.GetRow("Accounts"))
- {
- var current = (Accounts) row;
- Console.WriteLine(current.Username);
- }
- Console.ReadKey();
- }
- #region Nested type: Accounts
- public struct Accounts
- {
- public string Password;
- public string Username;
- }
- #endregion
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement