RobThree / MongoRepository

Repository abstraction layer on top of Official MongoDB C# driver
https://www.nuget.org/packages/MongoRepository/
MIT License
307 stars 141 forks source link

Add new methods to MongoRepository #9

Closed dalton5 closed 9 years ago

dalton5 commented 9 years ago

Hi,

I would like to exetend the standard MongoRepository class. I try to inherit from MongoRepository<t>.

public class CustomMongoRepository<T> : MongoRepository<T>{}

but it does not work.

Is it possible to do it?

I would like to add some standard methods such as AddOrUpdate(string key) ...

Thanks,

RobThree commented 9 years ago

but it does not work.

Define "does not work". What doesn't work? I think your problem is you're missing the generic constraint where T : IEntity<TKey>. So you should probably write something like:

public class CustomMongoRepository<T> : MongoRepository<T>
    where T : IEntity<string> { }

Also, the Update() method is, effectively, an AddOrUpdate method.

dalton5 commented 9 years ago

Great. It works. Thanks.