예제 #1
0
        public static ConcurrentBag <Inspection> GetInspections()
        {
            var inspections = new ConcurrentBag <Inspection>();

            using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["Conn"].ConnectionString))
            {
                conn.Open();
                string queryString = "SELECT FacilityLicID, InspectionID, InspectionStart, NumViolations, Page FROM dbo.Inspections";

                SqlCommand command = new SqlCommand(queryString, conn);
                var        reader  = command.ExecuteReader();
                while (reader.Read())
                {
                    Inspection i = new Inspection(Int32.Parse(reader["FacilityLicID"].ToString()), Int32.Parse(reader["InspectionID"].ToString()));
                    i.Page = reader["Page"].ToString();
                    inspections.Add(i);
                }
            }
            return(inspections);
        }