/// <summary> /// Gets a collection from the database. /// </summary> /// <remarks> /// The <see href="https://mongodb.github.io/mongo-csharp-driver/2.11/">MongoDB Bson</see> library is used /// to decode the response. It will automatically handle most cases, but if you want to control the behavior /// of the deserializer, you can use the attributes in the /// <see href="https://mongodb.github.io/mongo-csharp-driver/2.11/apidocs/html/N_MongoDB_Bson_Serialization_Attributes.htm">MongoDB.Bson.Serialization.Attributes</see> /// namespace. /// <br/> /// If you want to modify the global conventions used when deserializing the response, such as convert /// camelCase properties to PascalCase, you can register a /// <see href="https://mongodb.github.io/mongo-csharp-driver/2.11/reference/bson/mapping/conventions/">ConventionPack</see>. /// </remarks> /// <typeparam name="TDocument">The managed type that matches the shape of the documents in the collection.</typeparam> /// <param name="name">The name of the collection.</param> /// <returns>A <see cref="Collection{TDocument}"/> instance that exposes an API for CRUD operations on its contents.</returns> public Collection <TDocument> GetCollection <TDocument>(string name) where TDocument : class { Argument.Ensure(IsNameValid(name), "Collection names must be non-empty and not contain '.' or the null character.", nameof(name)); var handle = MongoCollectionHandle.Create(Client.User.Handle, Client.ServiceName, Name, name); return(new Collection <TDocument>(this, name, handle)); }
internal Collection(Database database, string name, MongoCollectionHandle handle) { Database = database; Name = name; _handle = handle; }