static void Main(string[] args)
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
            BookstoreDAL dal = new BookstoreDAL();

            XmlDocument xmlDoc = new XmlDocument();
            //xmlDoc.Load("../../simple-books.xml");
            xmlDoc.Load("../../../tests/5/simple-books.xml");
            string xPathQuery = "/catalog/book";

            XmlNodeList books = xmlDoc.SelectNodes(xPathQuery);

            using (var context = new BookstoreEntities())
            {
                foreach (XmlNode bookNode in books)
                {
                    string title = GetChildText(bookNode, "title");
                    if (string.IsNullOrEmpty(title))
                    {
                        throw new ArgumentException("The Book <title> node is empty or missing",
                            "title");
                    }

                    string ISBN = GetChildText(bookNode, "isbn");
                    string priceString = GetChildText(bookNode, "price");
                    decimal? price = null;
                    if (priceString != null)
                    {
                        price = decimal.Parse(priceString);
                    }

                    string websiteUrl = GetChildText(bookNode, "web-site");

                    List<string> authorNames = new List<string>();
                    foreach (XmlNode authorNode in bookNode.SelectNodes("author"))
                    {
                        string authorName = authorNode.InnerText.Trim();
                        if (authorName == String.Empty)
                        {
                            throw new ArgumentException("Author name cannot be empty.");
                        }

                        authorNames.Add(authorName);
                    }

                    if (authorNames.Count == 0)
                    {
                        throw new ArgumentException("The <author> node is empty or missing.",
                            "author");
                    }

                    using (var tran = new TransactionScope())
                    {
                        dal.AddBook(context, authorNames, title, ISBN, price, websiteUrl);

                        tran.Complete();
                    }
                }
            }
        }
        static void Main(string[] args)
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
            BookstoreDAL dataAccessLayer = new BookstoreDAL();

            XmlDocument xmlDoc = new XmlDocument();
            //xmlDoc.Load("../../complex-books.xml");
            //xmlDoc.Load(@"../../../tests/4/test-transaction.xml");
            xmlDoc.Load(@"../../../tests/5/complex-books.xml");
            string xPathQuery = "/catalog/book";

            XmlNodeList books = xmlDoc.SelectNodes(xPathQuery);

            using (var context = new BookstoreEntities())
            {
                foreach (XmlNode bookNode in books)
                {
                    string title = GetChildText(bookNode, "title");
                    if (string.IsNullOrEmpty(title))
                    {
                        throw new ArgumentException("The Book <title> node is empty or missing",
                            "title");
                    }

                    string ISBN = GetChildText(bookNode, "isbn");
                    string priceString = GetChildText(bookNode, "price");
                    decimal? price = null;
                    if (priceString != null)
                    {
                        price = decimal.Parse(priceString);
                    }

                    string websiteUrl = GetChildText(bookNode, "web-site");

                    List<string> authorNames = new List<string>();
                    foreach (XmlNode authorNode in bookNode.SelectNodes("authors/author"))
                    {
                        authorNames.Add(authorNode.InnerText);
                    }

                    Book addedBook =
                        dataAccessLayer.AddBook(context, authorNames, title,
                        ISBN, price, websiteUrl);

                    using (var tran = new TransactionScope())
                    {
                        foreach (XmlNode reviewNode in bookNode.SelectNodes("reviews/review"))
                        {
                            ProcessReviewNode(context, dataAccessLayer, addedBook, reviewNode);
                        }

                        tran.Complete();
                    }
                }
            }
        }