static void WriteResultSet(XmlTextWriter writer, ReviewsDAO reviewsDao, XmlNode queryNode)
        {
            IEnumerable<FoundReviewTransferObject> foundReviews = null;
            string searchType = queryNode.Attributes["type"].InnerText;
            if (searchType == "by-period")
            {
                DateTime startDate = DateTime.Parse(
                    queryNode.SelectSingleNode("start-date").InnerXml);

                DateTime endDate = DateTime.Parse(
                    queryNode.SelectSingleNode("end-date").InnerXml);
                foundReviews = reviewsDao.GetReviewsByPeriod(startDate, endDate);
            }
            else if (searchType == "by-author")
            {
                string authorName = queryNode.SelectSingleNode("author-name")
                    .InnerXml.Trim().ToLower();
                foundReviews = reviewsDao.GetReviewsByAuthorName(authorName);
            }
            else
            {
                return;
            }

            writer.WriteStartElement("result-set");
            if (foundReviews != null)
            {
                foreach (var review in foundReviews)
                {
                    WriteFoundReview(writer, review);
                }
            }

            writer.WriteEndElement();
        }
        static void Main()
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

            XmlDocument queryDocument = new XmlDocument();
            queryDocument.Load("../../reviews-queries.xml");
            using (XmlTextWriter writer = new XmlTextWriter("../../reviews-search-results.xml", Encoding.UTF8))
            {
                InitializeWriter(writer);

                writer.WriteStartDocument();
                writer.WriteStartElement("search-results");

                ReviewsDAO reviewsDao = new ReviewsDAO();

                using (LogsContext logsContext = new LogsContext())
                {
                    XmlNodeList queryNodes = queryDocument.SelectNodes("/review-queries/query");
                    foreach (XmlNode queryNode in queryNodes)
                    {
                        LogQuery(logsContext, queryNode.OuterXml);

                        WriteResultSet(writer, reviewsDao, queryNode);
                    }

                    writer.WriteEndDocument();
                }
            }

            Console.WriteLine("Done! See the file in project's directory.");
        }