internal CatalogExcursion CatalogExcursion(DataRow row)
            {
                CatalogExcursion result = new CatalogExcursion
                {
                    id   = row.ReadInt("excurs$inc"),
                    name = row.ReadNullableTrimmedString("excurs$name"),
                    url  = row.ReadNullableTrimmedString("excurs$url"),

                    excursionPartner = row.IsNull("expartner$inc") ? null : new Partner
                    {
                        id   = row.ReadInt("expartner$inc"),
                        name = row.ReadNullableTrimmedString("expartner$name")
                    },
                    text = row.ReadNullableTrimmedString("excurs$route")
                };

                System.DateTime?durationDate = row.ReadNullableUnspecifiedDateTime("excurs$lasting");
                if (durationDate.HasValue)
                {
                    result.duration = new System.TimeSpan?(durationDate.Value - new System.DateTime(1900, 1, 1));
                }
                XElement destinationXml = row.ReadXml("excurs$destinationpoints");

                if (destinationXml != null)
                {
                    result.destinations = (
                        from d in destinationXml.Descendants()
                        select new GeoArea
                    {
                        id = (int)d.Attribute("inc"),
                        alias = (string)d.Attribute("alias"),
                        name = (string)d.Attribute("name"),
                        location = (d.Attribute("latitude") == null || d.Attribute("longitude") == null) ? null : new GeoLocation
                        {
                            latitude = (decimal)d.Attribute("latitude"),
                            longitude = (decimal)d.Attribute("longitude")
                        }
                    }).ToList <GeoArea>();
                }
                XElement departureXml = row.ReadXml("excurs$departurepoints");

                if (departureXml != null)
                {
                    result.departures = (
                        from d in departureXml.Descendants()
                        select new GeoArea
                    {
                        id = (int)d.Attribute("inc"),
                        alias = (string)d.Attribute("alias"),
                        name = (string)d.Attribute("name"),
                        location = (d.Attribute("latitude") == null || d.Attribute("longitude") == null) ? null : new GeoLocation
                        {
                            latitude = (decimal)d.Attribute("latitude"),
                            longitude = (decimal)d.Attribute("longitude")
                        }
                    }).ToList <GeoArea>();
                }
                XElement languagesXml = row.ReadXml("excurs$languages");

                if (languagesXml != null)
                {
                    result.languages = (
                        from d in languagesXml.Descendants()
                        select new Language
                    {
                        id = (int)d.Attribute("inc"),
                        alias = (string)d.Attribute("alias"),
                        name = (string)d.Attribute("name")
                    }).ToList <Language>();
                }
                XElement categoriesXml = row.ReadXml("excurs$categories");

                if (categoriesXml != null)
                {
                    result.categories = (
                        from d in categoriesXml.Descendants()
                        select new ExcursionCategory
                    {
                        id = (int)d.Attribute("inc"),
                        name = (string)d.Attribute("name"),
                        categorygroup = (!((int?)d.Attribute("groupinc")).HasValue) ? null : new CategoryGroup
                        {
                            id = (int)d.Attribute("groupinc"),
                            name = (string)d.Attribute("groupname")
                        },
                        sort = (int?)d.Attribute("sort")
                    }).ToList <ExcursionCategory>();
                }
                return(result);
            }
 public static System.Collections.Generic.List <CatalogFilterCategoryGroup> BuildDescriptionCategories(CatalogExcursion catalog)
 {
     ExcursionProvider.CatalogFilterItemsCounterBuilder <ExcursionCategory> builder = new ExcursionProvider.CatalogFilterItemsCounterBuilder <ExcursionCategory>();
     if (catalog != null && catalog.categories != null)
     {
         foreach (ExcursionCategory c in catalog.categories)
         {
             builder.Add(c.id, c);
         }
     }
     return((
                from m in (
                    from m in builder.ToList()
                    group m by(m.item.categorygroup != null) ? m.item.categorygroup.name : null).Select(delegate(IGrouping <string, ExcursionProvider.CatalogFilterItemsCounterBuilder <ExcursionCategory> .CatalogFilterCounterItem <ExcursionCategory> > m)
     {
         CatalogFilterCategoryGroup catalogFilterCategoryGroup = new CatalogFilterCategoryGroup();
         catalogFilterCategoryGroup.name = m.Key;
         catalogFilterCategoryGroup.items = (
             from n in m
             orderby n.item.sort
             select new CatalogFilterItem
         {
             id = n.item.id,
             name = n.item.name,
             count = 0
         }).ToList <CatalogFilterItem>();
         return catalogFilterCategoryGroup;
     })
                orderby(m.name == null) ? 0 : 1, m.name
                select m).ToList <CatalogFilterCategoryGroup>());
 }