コード例 #1
0
 /// <summary>
 /// Creates a <see cref="University"/> instance in the database
 /// </summary>
 /// <param name="university">
 /// The <see cref="University"/> instance to persist to the database
 /// </param>
 public void Create(University university)
 {
     using (var context = new DnugContext(this.connectionString))
     {
         context.Universities.Add(university);
         context.SaveChanges();
     }
 }
コード例 #2
0
 /// <summary>
 /// Deletes the <see cref="University"/> instance with the specified <see cref="id"/>
 /// </summary>
 /// <param name="id">
 /// The id of the <see cref="University"/> to delete
 /// </param>
 public void Delete(Guid id)
 {
     using (var context = new DnugContext(this.connectionString))
     {
         University university = (from u in context.Universities
                                  where u.Id == id
                                  select u).First();
         context.Universities.Remove(university);
         context.SaveChanges();
     }
 }
コード例 #3
0
 /// <summary>
 /// Updates a scalar property on the <see cref="University"/> instance associated to the <see cref="id"/> parameter
 /// </summary>
 /// <param name="id">
 /// The id of the <see cref="University"/> to load
 /// </param>
 /// <param name="name">
 /// The new name to apply to the <see cref="University"/>
 /// </param>
 public void Update(Guid id, string name)
 {
     using (var context = new DnugContext(this.connectionString))
     {
         University university = (from u in context.Universities
                                  where u.Id == id
                                  select u).First();
         university.Name = name;
         context.SaveChanges();
     }
 }