Ejemplo n.º 1
0
 private Stat SaveChanges(MGFContext entities, DataEntities.Stat entity)
 {
     // Save everything in the context (unit of work means it should only be this entity and anything it contains)
     entities.SaveChanges();
     // reload what the database has based on the ID that we modified
     return(Fetch(entity.StatId));
 }
Ejemplo n.º 2
0
 static void Main(string[] args)
 {
     using (MGFContext entities = new MGFContext())
     {
         User user = new User()
         {
             LoginName = "admin"
         };
         entities.Users.Add(user);
         entities.SaveChanges();
     }
 }
Ejemplo n.º 3
0
 protected override void DeleteNow(int id)
 {
     using (MGFContext entities = new MGFContext())
     {
         MGF.DataEntities.Stat entity = new DataEntities.Stat {
             StatId = id
         };
         // Gets the character list and attaches the entity to the contain (makes this object exist in the list of objects).
         entities.Stats.Attach(entity);
         // Remove the character from the container
         entities.Stats.Remove(entity);
         entities.SaveChanges();
     }
 }