protected static void Create <TDataType>(MongoConnection connection, TDataType data) where TDataType : AbstractMongoData { data._id = ObjectId.GenerateNewId(DateTime.Now); IMongoCollection <TDataType> datas = connection.Database.GetCollection <TDataType>(typeof(TDataType).Name); Task insertTask = datas.InsertOneAsync(data); MongoDataHelper.WaitForTaskOrThrowTimeout(insertTask); }
public void Create(MongoConnection connection) { _id = ObjectId.GenerateNewId(DateTime.Now); LastWorkTime = DateTime.Now; IMongoCollection <Worker> datas = connection.Database.GetCollection <Worker>(typeof(Worker).Name); Task insertTask = datas.InsertOneAsync(this); MongoDataHelper.WaitForTaskOrThrowTimeout(insertTask); }