コード例 #1
0
 /// <summary>
 /// Loads the Entire Skill object with all related data.
 /// </summary>
 /// <param name="id">the ID of the Skill</param>
 /// <returns>a Skill</returns>
 public Skill LoadByID(int id)
 {
     using (var DB = new ShadowDBContext(ConStr, DBType)) {
         return(DB.Skills.Include(s => s.Specializations)
                .Include(s => s.Group)
                .FirstOrDefault(s => s.ID == id));
     }
 }
コード例 #2
0
 public void Delete(Skill skill)
 {
     using (var DB = new ShadowDBContext(ConStr, DBType)) {
         var specs = DB.Specializations.Where(sp => sp.Skill == skill);
         DB.Specializations.RemoveRange(specs);
         DB.Skills.Remove(skill);
         DB.SaveChanges();
     }
 }
コード例 #3
0
 /// <summary>
 /// Saves a Skill to the database
 /// </summary>
 /// <param name="skill">the skill to be saved</param>
 public void Save(Skill skill)
 {
     using (var DB = new ShadowDBContext(ConStr, DBType)) {
         var specs = DB.Specializations
                     .Where(sp => (sp.Skill == skill) && (!skill.Specializations.Contains(sp)));
         DB.RemoveRange(specs);
         DB.Skills.Update(skill);
         DB.SaveChanges();
     }
 }
コード例 #4
0
 /// <summary>
 /// Generate LookupItems from all the skills in the database
 /// </summary>
 /// <returns>Collection of LookupItems</returns>
 public IEnumerable <LookupItem> LookupItems()
 {
     using (var DB = new ShadowDBContext(ConStr, DBType)) {
         return(DB.Skills.Select(s => new LookupItem(s.ID, s.Name)).ToArray());
     }
 }
コード例 #5
0
 /// <summary>
 /// Loads the skill groups from the database
 /// </summary>
 /// <returns>Collection of SkillGroup</returns>
 public IEnumerable <SkillGroup> LoadSkillGroups()
 {
     using (var DB = new ShadowDBContext(ConStr, DBType)) {
         return(DB.SkillGroups.ToList());
     }
 }