/// <summary> /// 创建一条数据 /// </summary> /// <param name="document">基于BsonDocument的数据</param> /// <param name="option">创建参数</param> /// <returns>是否成功</returns> protected async Task <bool> CreateAsync(BsonDocument document, InsertOneOptions option = null) { try { await BsonDBContext.InsertOneAsync(document, option); return(true); } catch { return(false); } }
/// <summary> /// 创建多条数据 /// </summary> /// <param name="documents">基于BsonDocument的数据列表</param> /// <param name="option">创建参数</param> /// <returns>是否成功</returns> protected async Task <bool> CreateManyAsync(IEnumerable <BsonDocument> documents, InsertManyOptions option = null) { try { await BsonDBContext.InsertManyAsync(documents, option); return(true); } catch { return(false); } }