public MongoRepository(MongoUrl url) { CollectionNameAttribute mongoCollectionName = (CollectionNameAttribute)typeof(T).GetTypeInfo().GetCustomAttribute(typeof(CollectionNameAttribute)); this.CollectionName = (mongoCollectionName != null ? mongoCollectionName.Name : typeof(T).Name.ToLower()); mongoCollectionName = null; this.Connect = new Connect(url); this.Collection = this.Connect.Collection <T>(this.CollectionName); }
public MongoRepository(IMongoDatabase mongoDatabase, string collectionName = null) { this.Connect = new Connect(mongoDatabase); if (string.IsNullOrEmpty(collectionName)) { CollectionNameAttribute mongoCollectionName = (CollectionNameAttribute)typeof(T).GetTypeInfo().GetCustomAttribute(typeof(CollectionNameAttribute)); collectionName = (mongoCollectionName != null ? mongoCollectionName.Name : typeof(T).Name.ToLower()); } this.Collection = this.Connect.Collection <T>(collectionName); }