public static bool AddTeacher(Teacher teacher) { var query = Query.EQ("TeaNo", teacher.TeaNo); if (collection.Find(query).Count() > 0) return false; else { collection.Insert<Teacher>(teacher); return true; } }
public static void Update(Teacher teacher) { collection.Update(new QueryDocument { { "_id", teacher.Id } }, new UpdateDocument { { "$set", new BsonDocument { {"TeaNo", teacher.TeaNo }, {"Name", teacher.Name}, {"Institution", teacher.Institution} }}}); }