private void LoopValuesToDatabase(SparqlResultSet resultSetAuthorDetails, SparqlResultSet resultSetAuthorBooks) { if (resultSetAuthorDetails.IsEmpty && resultSetAuthorBooks.IsEmpty) { return; } string authorLink = resultSetAuthorDetails.Last()["authorLink"].ToString(); string authorName = resultSetAuthorDetails.Last()["authorName"].ToString(); string placeOfBirthLink = resultSetAuthorDetails.Last()["placeOfBirthLink"].ToString(); string placeOfBirth = resultSetAuthorDetails.Last()["PlaceOfBirth"].ToString(); string stringLatitude = resultSetAuthorDetails.Last().Value("latitude").ToString(); string stringLongitude = resultSetAuthorDetails.Last().Value("longitude").ToString(); //Convert latitude and longitude to float float latitude = float.Parse(Utilities.NumberConverter(stringLatitude)); float longitude = float.Parse(Utilities.NumberConverter(stringLongitude)); if (authorName.Length > 3 && placeOfBirth.Length > 3) { authorName = authorName.Substring(0, authorName.Length - 3); placeOfBirth = placeOfBirth.Substring(0, placeOfBirth.Length - 3); } //Create a list of all the authors books List <BookDetails> authorBooks = new List <BookDetails>(); foreach (SparqlResult result in resultSetAuthorBooks) { string bookLink = result["bookLink"].ToString(); string name = result["bookName"].ToString(); string bookAbstract = result["bookAbstract"].ToString(); string stringNumberOfPages = ""; if (result["numberOfPages"] != null) { stringNumberOfPages = result["numberOfPages"].ToString(); } string comment = result["comment"].ToString(); //Remove @en from the string name = Utilities.RemoveLast3Cahracters(name); bookAbstract = Utilities.RemoveLast3Cahracters(bookAbstract); comment = Utilities.RemoveLast3Cahracters(comment); //Convert numberOfPages to int int numberOfPages = 0; if (result["numberOfPages"] != null) { numberOfPages = int.Parse(Utilities.NumberConverter(stringNumberOfPages)); } //Create a BookDetails object BookDetails book = new BookDetails { BookLink = bookLink, Name = name, Abstract = bookAbstract, NumberOfPages = numberOfPages, Comment = comment }; authorBooks.Add(book); } // AddToDatabase(authorLink, authorName, placeOfBirthLink, placeOfBirth, latitude, longitude, authorBooks); }