예제 #1
0
 public void SaveRecord(Record newRecord)
 {
     using (var dc = new EfRecordDbContext())
     {
         var entity = newRecord.ToEntity();
         dc.Records.Add(entity);
         dc.SaveChanges();
     }
 }
예제 #2
0
 public Record GetRecord(string phone)
 {
     using (var dc = new EfRecordDbContext())
     {
         var dbRecord = dc.Records.Single(entity => entity.Phone.Equals(phone, StringComparison.InvariantCultureIgnoreCase));
         var result = dbRecord.ToModel();
         return result;
     }
 }
예제 #3
0
 public IEnumerable<Record> GetRecords(string firstOrLastNameFragment)
 {
     firstOrLastNameFragment = firstOrLastNameFragment.ToLowerInvariant();
     using (var dc = new EfRecordDbContext())
     {
         var dbRecords = dc.Records
                     .Where(entity => entity.FirstName.Contains(firstOrLastNameFragment)
                                                 || entity.LastName.Contains(firstOrLastNameFragment))
                     .ToArray();
         var result = dbRecords.Select(entity => entity.ToModel());
         return result;
     }
 }