Ejemplo n.º 1
0
        static void Main()
        {
            // Prepare

            var examples = new Examples();

            examples.CreateTable();

            // Create

            int id;

            if (Bill.GetCount() < 1)
            {
                id = examples.Create();
                Console.WriteLine("Bill created with Id: {0}", id);
            }
            else
            {
                id = Bill.GetAll().First().Id;
                Console.WriteLine("Bill already exists with Id: {0}", id);
            }

            // Retrieve

            var bills = examples.Retrieve().ToList();

            Console.WriteLine("Bills in table:");
            bills.ForEach(x => Console.WriteLine("{0}\t{1}\t{2}", x.Id, x.Name, x.Date.ToShortDateString()));

            // Update

            examples.Update(id, "Bill new name");

            // Retrieve by Id

            var bill = examples.Retrieve(id);

            Console.WriteLine("Bill name is: {0}", bill.Name);

            // Delete

            examples.Delete(id);

            // Migrate

            examples.MigrateToLast();

            // Drop table

            new SQLiteDatabase().ExecuteQuery(string.Concat("DROP TABLE ", Bill.TableName));

            // Wait

            Console.ReadKey();
        }
Ejemplo n.º 2
0
        static void Main()
        {
            // Prepare

            var examples = new Examples();
            examples.CreateTable();

            // Create

            int id;
            if (Bill.GetCount() < 1)
            {
                id = examples.Create();
                Console.WriteLine("Bill created with Id: {0}", id);
            }
            else
            {
                id = Bill.GetAll().First().Id;
                Console.WriteLine("Bill already exists with Id: {0}", id);
            }

            // Retrieve

            var bills = examples.Retrieve().ToList();
            Console.WriteLine("Bills in table:");
            bills.ForEach(x => Console.WriteLine("{0}\t{1}\t{2}", x.Id, x.Name, x.Date.ToShortDateString()));

            // Update

            examples.Update(id, "Bill new name");
   
            // Retrieve by Id

            var bill = examples.Retrieve(id);
            Console.WriteLine("Bill name is: {0}", bill.Name);

            // Delete

            examples.Delete(id);

            // Migrate

            examples.MigrateToLast();

            // Drop table

            new SQLiteDatabase().ExecuteQuery(string.Concat("DROP TABLE ", Bill.TableName));

            // Wait

            Console.ReadKey();
        }