mlockett42 / litedb-async

This library allows the use of asynchronous programming techniques with the LiteDb library
Apache License 2.0
104 stars 13 forks source link

Add ability to access underlying database #8

Closed mookid8000 closed 4 years ago

mookid8000 commented 4 years ago

This PR adds a GetUnderlyingDatabase method to LiteDatabaseAsync, so that one can retrieve the wrapped ILiteDatabase.

This is useful, because ILiteDatabase exposes various operations not available otherwise – e.g. the ability to rebuild the database with another collation:

var collation = new Collation(CultureInfo.InvariantCulture.LCID, CompareOptions.Ordinal);

database.GetUnderlyingDatabase().Rebuild(new RebuildOptions {Collation = collation});

this way providing a way to make the database's string comparisons case sensitive.

mlockett42 commented 4 years ago

Instead of a method we should have a read only property.

See the answers to this stack overflow question https://stackoverflow.com/questions/16829732/to-use-a-read-only-property-or-a-method

Also please target the new incoming branch I expect you wil need a new PR.

Edit: Github won't let me repon this PR because I deleted the master branch

mookid8000 commented 4 years ago

Oh yeah, sure thing 🙂 I added it as a method because I thought it matched GetUnderlyingCollection of LiteCollectionAsync nicely, but if you prefer a read-only property I can definitely change it into that.

mlockett42 commented 4 years ago

I should probably change that too. Just an old habit from when I was a C++ programmer