Skip to content

Instantly share code, notes, and snippets.

@mizrael
Created December 16, 2015 22:23
Show Gist options
  • Save mizrael/7e75d7f14cb2971997fa to your computer and use it in GitHub Desktop.
Save mizrael/7e75d7f14cb2971997fa to your computer and use it in GitHub Desktop.
basic C# interface for a MongoDB repository
public interface IRepository<TEntity>
{
string CollectionName { get; }
Task<long> CountAsync(FilterDefinition<TEntity> filter);
IFindFluent<TEntity, TEntity> Find(FilterDefinition<TEntity> filter);
IFindFluent<TEntity, TEntity> Find(Expression<Func<TEntity, bool>> filter);
Task<TEntity> FindOneAndReplaceAsync(FilterDefinition<TEntity> filter, TEntity replacement);
Task<TEntity> FindOneAndReplaceAsync(Expression<Func<TEntity, bool>> filter, TEntity replacement);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment