Esempio n. 1
0
        public static void Main()
        {
            using (var context = new GeographyEntities())
            {
                var query = context.Rivers
                    .OrderByDescending(o => o.Length)
                    .Select(r => new
                {
                    Name = r.RiverName, r.Length,
                    Countries = r.Countries
                    .OrderBy(o => o.CountryName)
                    .Select(c => c.CountryName)
                });
//
//                foreach (var river in query)
//                {
//                    Console.WriteLine(river.Name + " - " + river.Length + " [ " + string.Join(", ",river.Countries) + " ]");
//                    
//                }

                var serializer = new JavaScriptSerializer();
                var json = serializer.Serialize(query);
                File.WriteAllText(@".\rivers.json", json, Encoding.UTF8);
            }
        }
Esempio n. 2
0
 public static void Main()
 {
     using (var context = new GeographyEntities())
     {
         foreach (var country in context.Countries)
         {
           Console.WriteLine(country.CountryName); 
         } 
     }
 }
        public static void Main()
        {
            using (var context = new GeographyEntities())
            {
                var query = context
                    .Countries.OrderBy(c => c.CountryName)
                    .Where(c=>c.Monasteries.Any())
                    .Select(c => new
                    {
                        c.CountryName,
                        Monasteries = c.Monasteries.OrderBy(m=>m.Name).Select(m=>m.Name)
                    });

                foreach (var country in query)
                {
                    Console.WriteLine(country.CountryName + ":\n\t- " + string.Join("\n\t- ", country.Monasteries));
                }

                XmlDocument doc = new XmlDocument();
            }
        }