public static System.Collections.Generic.List <ExcursionDescription> GetDescription(string lang, int[] excursions)
        {
            if (excursions == null)
            {
                throw new System.ArgumentNullException("excursions");
            }
            XElement xml = new XElement("excursions",
                                        from e in excursions
                                        select new XElement("excursion", new XAttribute("id", e)));
            DataSet ds = DatabaseOperationProvider.QueryProcedure("up_guest_getExcursionDescription", "excursions,pictures,dtree,description", new
            {
                language        = lang,
                excursions      = xml,
                loaddescription = true
            });

            System.Collections.Generic.IEnumerable <ExcursionPicture> pictures =
                from DataRow row in ds.Tables["pictures"].Rows
                select ExcursionProvider.factory.ExcursionPicture(row);

            return(ds.Tables["excursions"].Rows.Cast <DataRow>().Select(delegate(DataRow row)
            {
                ExcursionDescription description = new ExcursionDescription();
                description.excursion = ExcursionProvider.factory.CatalogExcursion(row);
                description.pictures = (
                    from p in pictures
                    where p.ex == description.excursion.id
                    select p).ToList <ExcursionPicture>();
                System.Collections.Generic.List <ExcursionProvider.EDSNode> tree = (
                    from DataRow r in ds.Tables["dtree"].Rows
                    select new ExcursionProvider.EDSNode
                {
                    id = r.ReadInt("inc"),
                    parentid = r.ReadNullableInt("parent_inc"),
                    section = ExcursionProvider.factory.ExcursionDescriptionSection(r)
                }).ToList <ExcursionProvider.EDSNode>();
                ExcursionProvider.EDSNode ctree = null;
                foreach (DataRow paragraphRow in
                         from DataRow r in ds.Tables["description"].Rows
                         where r.ReadInt("excurs") == description.excursion.id
                         select r)
                {
                    int treeId = paragraphRow.ReadInt("tree");
                    if (ctree == null || ctree.id != treeId)
                    {
                        ctree = tree.FirstOrDefault((ExcursionProvider.EDSNode r) => r.id == treeId);
                    }
                    if (ctree != null)
                    {
                        if (ctree.section.paragraphs == null)
                        {
                            ctree.section.paragraphs = new System.Collections.Generic.List <string>();
                        }
                        ctree.section.paragraphs.Add(paragraphRow.ReadNullableTrimmedString((!paragraphRow.IsNull("descriptionlang")) ? "descriptionlang" : "description"));
                    }
                }
                description.description = new System.Collections.Generic.List <ExcursionDescriptionSection>();
                foreach (ExcursionProvider.EDSNode tnode in tree)
                {
                    if (!ExcursionProvider.EDSNode.IsNodeEmpty(tree, tnode))
                    {
                        if (!tnode.parentid.HasValue)
                        {
                            description.description.Add(tnode.section);
                        }
                        else
                        {
                            ExcursionProvider.EDSNode pnode = tree.FirstOrDefault((ExcursionProvider.EDSNode r) => r.id == tnode.parentid.Value);
                            if (pnode != null)
                            {
                                if (pnode.section.sections == null)
                                {
                                    pnode.section.sections = new System.Collections.Generic.List <ExcursionDescriptionSection>();
                                }
                                pnode.section.sections.Add(tnode.section);
                            }
                        }
                    }
                }
                return description;
            }).ToList <ExcursionDescription>());
        }
            public static bool IsNodeEmpty(System.Collections.Generic.List <ExcursionProvider.EDSNode> list, ExcursionProvider.EDSNode node)
            {
                bool result;

                if (node.section.paragraphs != null)
                {
                    result = false;
                }
                else
                {
                    foreach (ExcursionProvider.EDSNode child in
                             from row in list
                             where row.parentid == node.id
                             select row)
                    {
                        if (!ExcursionProvider.EDSNode.IsNodeEmpty(list, child))
                        {
                            result = false;
                            return(result);
                        }
                    }
                    result = true;
                }
                return(result);
            }