public static void LoadMessages(List<Message> dialogs)
        {
            for (int i = 0; i < dialogs.Count; i++)
            {
                Message msg = dialogs[i];
                HttpRequestsHandler.GetUserByID(msg.uid, (x) =>
                {
                    using (VKDataContext context = new VKDataContext(VKDataContext.DBConnectionString))
                    {
                        VKMessage vm = new VKMessage();
                        vm.Body = msg.body;
                        vm.Date = DateConverter.DateTimeFromUnixTimestampSeconds(msg.date);
                        vm.VKMessageID = msg.mid;
                        VKUser user = new VKUser();

                        user.FirstName = x.first_name;
                        user.LastName = x.last_name;
                        user.IsOnline = (x.online == 1);
                        user.VKUserID = x.uid;

                        context.VKUser.InsertOnSubmit(user);
                        context.SubmitChanges();

                        context.VKMessage.InsertOnSubmit(vm);
                        context.SubmitChanges();

                        UserMessage um = new UserMessage();
                        um.VKMessageID = user.VKUserID;
                        um.VKUserID = vm.VKMessageID;

                        context.UserMessage.InsertOnSubmit(um);
                        context.SubmitChanges();
                    }
                }, (error) =>
                {
                });
            }
        }
        private void createTestData()
        {
            using (VKDataContext context = new VKDataContext(VKDataContext.DBConnectionString))
            {
                //context.DeleteDatabase();
                //context.CreateDatabase();

                IList<String> firstnames = new List<String>();
                firstnames.Add("Александр");
                firstnames.Add("Андрей");
                firstnames.Add("Bob");
                firstnames.Add("Willy");
                firstnames.Add("John");
                firstnames.Add("Akakij");

                IList<String> lastnames = new List<String>();
                lastnames.Add("Семирухин");
                lastnames.Add("White");
                lastnames.Add("Green");
                lastnames.Add("Joke");
                lastnames.Add("Smith");
                lastnames.Add("Васильев");

                IList<String> messageBodies = new List<String>();
                messageBodies.Add("Hi! How are you?");
                messageBodies.Add("Привет! Как дела?");
                messageBodies.Add("Merhaba! Nasilsin?");
                messageBodies.Add("What's up?");
                messageBodies.Add("Йоххо!");
                messageBodies.Add("London is capital of Great Britain");

                for (int i = 0; i < 6; i++)
                {
                    VKUser user = new VKUser();
                    user.LastName = lastnames[i];
                    user.FirstName = firstnames[i];
                    user.Photo = "http://photo.jpg";
                    user.IsOnline = true;
                    context.VKUser.InsertOnSubmit(user);
                    context.SubmitChanges();

                    VKMessage message = new VKMessage();
                    message.Body = messageBodies[i];
                    context.VKMessage.InsertOnSubmit(message);
                    context.SubmitChanges();

                    UserMessage um = new UserMessage();
                    um.VKMessageID = user.VKUserID;
                    um.VKUserID = message.VKMessageID;
                    context.UserMessage.InsertOnSubmit(um);
                    context.SubmitChanges();
                }
            }
        }