Exemplo n.º 1
0
        public void QueryStruct()
        {
            IConnection connection = Program.GetOpenConnection();

            if (!connection.ExistTable <UserStruct>())
            {
                connection.CreateTable <UserStruct>();
            }

            try
            {
                UserStruct user1 = new UserStruct {
                    id = 1, username = "******", password = "******"
                };
                UserStruct user2 = new UserStruct {
                    id = 2, username = "******", password = "******"
                };

                connection.Insert(user1);
                connection.Insert(user2);

                Console.WriteLine(user1);
                Console.WriteLine(user2);

                user1 = connection.Get <UserStruct>("un2");
                Console.WriteLine("Get user struct 2: " + user1);
            }
            finally
            {
                connection.DropTable <UserStruct>();
                connection.Close();
            }
        }
Exemplo n.º 2
0
        public void QueryStruct()
        {
            IConnection connection = Program.GetOpenConnection();

            if (!connection.ExistTable<UserStruct>())
                connection.CreateTable<UserStruct>();

            try
            {
                UserStruct user1 = new UserStruct { id = 1, username = "******", password = "******" };
                UserStruct user2 = new UserStruct { id = 2, username = "******", password = "******" };

                connection.Insert(user1);
                connection.Insert(user2);

                Console.WriteLine(user1);
                Console.WriteLine(user2);

                user1 = connection.Get<UserStruct>("un2");
                Console.WriteLine("Get user struct 2: " + user1);
            }
            finally
            {
                connection.DropTable<UserStruct>();
                connection.Close();
            }
        }