Example #1
0
        public void Insert(SQLiteConnection connection, int numberOfItems)
        {
            for (var i = 0; i < numberOfItems; i++)
            {
                var news = new News
                {
                    Title = "Headline " + i
                };

                News.Add(news);
                connection.Insert(news);
            }
        }
        public void Insert(SQLiteConnection connection, int numberOfUsers)
        {
            var r = new Random();
            for (var i = 0; i < numberOfUsers; i++)
            {
                var user = new SimpleUser
                {
                    FirstName = "First" + i,
                };

                Users.Add(user);

                connection.Insert(user);
            }
        }
        public void Insert(SQLiteConnection connection, int count)
        {
            Random r = new Random();
            for (int i = 0; i < count; i++)
            {
                var item = new Message
                {
                    Title = "Ttl" + i,
                    Body = "Hello world " + Guid.NewGuid().ToString(),
                    ReceivedAt = DateTime.Now.AddSeconds(r.Next(-10000, 0)),
                };

                Items.Add(item);

                connection.Insert(item);
            }
        }
Example #4
0
        public void Insert(SQLiteConnection connection, int numberOfUsers)
        {
            var r = new Random();
            for (var i = 0; i < numberOfUsers; i++)
            {
                var user = new User
                {
                    FirstName = "First" + i,
                    LastName = Guid.NewGuid().ToString(),
                    Id = Guid.NewGuid(),
                    DateOfBirth = DateTime.Today.AddDays(r.Next(-100, 100)),
                    MessageCount = i + 10
                };

                Users.Add(user);

                connection.Insert(user);
            }
        }
Example #5
0
        public Post Create(Post post)
        {
            if (post == null)
            {
                return null;
            }

            using (var conn = new SQLiteConnection(Connectionstring))
            {
                conn.Open();

                var postid = conn.Insert(post);
                post.Id = (int)postid;

                conn.Close();
            }

            return post.Id > 0 ? post : null;
        }
        void HandleTouchUpInsideForInsertUser(object sender, EventArgs e)
        {
            var person = new Person { FirstName = "John " + DateTime.Now.Ticks, LastName = "Doe"};
            using (var db = new SQLite.SQLiteConnection(_pathToDatabase ))
            {
                db.Insert(person);
            }

            _txtView.Text += String.Concat(Environment.NewLine, "Inserted a new person into the database: ", person.FirstName, " ", person.LastName);
        }