예제 #1
0
        public void Execute()
        {
            var db            = new UnitOfWork(new PhotographyContext());
            var photographers =
                db.PhotographersRepo
                .GetAll()
                .Select(p => new
            {
                p.FirstName,
                p.LastName,
                p.Phone
            })
                .OrderBy(p => p.FirstName)
                .ThenByDescending(p => p.LastName);

            var json = ExportJsonToFile.ExportQueryToFile(photographers, "../../JsonsExports/photographers-ordered.json");

            Console.WriteLine(json);
        }
예제 #2
0
        public void Execute()
        {
            var db            = new UnitOfWork(new PhotographyContext());
            var photographers =
                db.PhotographersRepo
                .GetAll()
                .ToList()
                .Where(p => p.PrimaryCamera.GetType() == typeof(DslrCamera))
                .Select(p => new
            {
                p.FirstName,
                p.LastName,
                CameraMake  = p.PrimaryCamera.Make,
                LensesCount = p.Lens.Count(l => l.FocalLength <= 30)
            });

            var json = ExportJsonToFile.ExportQueryToFile(photographers, "../../JsonsExports/photographers-ordered.json");

            Console.WriteLine(json);
        }