private void Backup(Database database, Dao dao)
 {
     if (database == SourceDatabase)
     {
         BackupTask = Task.Run(() =>
         {
             object dtoInstance = Dto.Copy(dao);
             object existing    = BackupRepository.Retrieve(dtoInstance.GetType(), dtoInstance.Property <string>("Uuid"));
             if (existing != null)
             {
                 BackupRepository.Save(dtoInstance);
             }
             else
             {
                 BackupRepository.Create(dtoInstance);
             }
         });
         BackupTask.ConfigureAwait(false);
     }
 }
        public void ShouldBeAbleToCopyDaoAsGeneratedDtoType()
        {
            SQLiteDatabase saveTo = GetTestDatabase(false);
            MainObject     toAdd  = new MainObject();

            toAdd.Name = 4.RandomLetters().Plus(":: The Name");
            toAdd.Save(saveTo);

            object dtoInstance = Dto.Copy(toAdd);

            OutLine("Dto info", ConsoleColor.Cyan);
            OutLineFormat("Type: {0}.{1}", dtoInstance.GetType().Namespace, dtoInstance.GetType().Name);
            OutLine(dtoInstance.TryPropertiesToString());

            MainObject daoInstance = MainObject.FirstOneWhere(c => c.Name == dtoInstance.Property("Name"), saveTo);

            Expect.IsNotNull(daoInstance);
            Expect.AreSame(saveTo, daoInstance.Database);
            OutLine("Dao info", ConsoleColor.Cyan);
            OutLineFormat("Type: {0}.{1}", daoInstance.GetType().Namespace, daoInstance.GetType().Name);
            OutLine(daoInstance.TryPropertiesToString());
        }