Exemple #1
0
        private void EFCoreQuery1()
        {
            var optionsBuilder = new DbContextOptionsBuilder <NPPESContext>();

            optionsBuilder.UseSqlServer(new SqlConnection(_connstr, _sqlcred));
            using (var db = new NPPESContext(optionsBuilder.Options))
            {
                // Read
                var locs = from service in db.HealthcareFacilityServices
                           where service.CountyName == "SAN FRANCISCO"
                           select new { service.Facid, service.Facname, service.OffsiteName, service.CountyName, service.ServiceTypeName };

                foreach (var loc in locs)
                {
                    Console.WriteLine($"{loc.Facid} | {loc.Facname} | {loc.OffsiteName} | {loc.CountyName} | {loc.ServiceTypeName}");
                }
            }
        }
Exemple #2
0
        private void EFCoreQuery2()
        {
            var optionsBuilder = new DbContextOptionsBuilder <NPPESContext>();

            optionsBuilder.UseSqlServer(new SqlConnection(_connstr, _sqlcred));
            using (var db = new NPPESContext(optionsBuilder.Options))
            {
                var locs = from location in db.HealthcareFacilityLocations
                           where location.CountyName == "SAN FRANCISCO"
                           orderby location.Capacity descending
                           select new { location.Facid, location.Facname, location.CountyName, location.Capacity };

                foreach (var loc in locs)
                {
                    Console.WriteLine($"{loc.Facid} | {loc.Facname} | {loc.CountyName} | {loc.Capacity}");
                }
            }
        }