コード例 #1
0
 public IEnumerable <Person> All()
 {
     using (var reader = new DelimitedDataReader("data.csv", true, 0, 0, ','))
     {
         while (reader.Read())
         {
             yield return(GetPerson(reader));
         }
     }
 }
コード例 #2
0
 private Person GetPerson(DelimitedDataReader reader)
 {
     return(new Person
     {
         Id = Convert.ToInt32(reader["id"]),
         FirstName = reader["first_name"],
         LastName = reader["last_name"],
         EmailAddress = reader["email"],
         Gender = (Gender)Enum.Parse(typeof(Gender), reader["gender"]),
         Country = reader["country"],
         Buzzwords = reader["buzzword"],
         Pets = petStore.GetRandom()
     });
 }