The MongoDbRepository now has a constructor that takes an IMongoDatabase.

This commit is contained in:
alexandre-spieser
2017-11-01 08:18:29 +00:00
parent fbb07475a1
commit 657beeac99
18 changed files with 52 additions and 29 deletions
@@ -1,10 +1,10 @@
using IntegrationTests.Infrastructure;
using CoreIntegrationTests.Infrastructure;
using MongoDbGenericRepository.Models;
using Xunit;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace IntegrationTests
namespace CoreIntegrationTests
{
public class CreateTestsPartitionedDocument : PartitionedDocument
{
+2 -2
View File
@@ -1,10 +1,10 @@
using IntegrationTests.Infrastructure;
using CoreIntegrationTests.Infrastructure;
using MongoDbGenericRepository.Models;
using Xunit;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace IntegrationTests
namespace CoreIntegrationTests
{
public class CreateTestsDocument : Document
{
@@ -1,9 +1,9 @@
using IntegrationTests.Infrastructure;
using CoreIntegrationTests.Infrastructure;
using MongoDbGenericRepository.Models;
using Xunit;
using System.Threading.Tasks;
namespace IntegrationTests
namespace CoreIntegrationTests
{
public class DeleteTestsPartitionedDocument : PartitionedDocument
{
+2 -2
View File
@@ -1,9 +1,9 @@
using IntegrationTests.Infrastructure;
using CoreIntegrationTests.Infrastructure;
using MongoDbGenericRepository.Models;
using Xunit;
using System.Threading.Tasks;
namespace IntegrationTests
namespace CoreIntegrationTests
{
public class DeleteTestsDocument : Document
{
+2 -4
View File
@@ -1,14 +1,12 @@
using IntegrationTests.Infrastructure;
using MongoDB.Bson.Serialization.Attributes;
using CoreIntegrationTests.Infrastructure;
using MongoDbGenericRepository.Models;
using System;
using System.Collections.Generic;
using System.Text;
using Xunit;
using Microsoft.AspNetCore.Identity;
using System.Threading.Tasks;
namespace CoreIntegrationTests
namespace CoreCoreIntegrationTests
{
public class MongoIdentityUser<TKey> : IdentityUser<TKey>, IDocument<TKey>
where TKey : IEquatable<TKey>
@@ -2,7 +2,7 @@
using System.Collections.Generic;
using System;
namespace IntegrationTests.Infrastructure
namespace CoreIntegrationTests.Infrastructure
{
public class BaseMongoDbRepositoryTests<T> : IDisposable where T : new()
@@ -1,6 +1,6 @@
using MongoDbGenericRepository;
namespace IntegrationTests
namespace CoreIntegrationTests
{
public interface ITestRepository : IBaseMongoRepository
{
@@ -1,9 +1,9 @@
using CoreIntegrationTests;
using CoreCoreIntegrationTests;
using MongoDB.Bson.Serialization;
using MongoDB.Bson.Serialization.Conventions;
using System.Threading;
namespace IntegrationTests.Infrastructure
namespace CoreIntegrationTests.Infrastructure
{
internal static class MongoDbConfig
{
@@ -1,6 +1,6 @@
using MongoDbGenericRepository;
namespace IntegrationTests.Infrastructure
namespace CoreIntegrationTests.Infrastructure
{
/// <summary>
/// A singleton implementation of the TestRepository
@@ -1,11 +1,11 @@
using IntegrationTests.Infrastructure;
using CoreIntegrationTests.Infrastructure;
using MongoDbGenericRepository.Models;
using Xunit;
using System;
using System.Linq;
using System.Threading.Tasks;
namespace IntegrationTests
namespace CoreIntegrationTests
{
public class ProjectTestsPartitionedDocument : PartitionedDocument
{
+2 -2
View File
@@ -1,11 +1,11 @@
using IntegrationTests.Infrastructure;
using CoreIntegrationTests.Infrastructure;
using MongoDbGenericRepository.Models;
using Xunit;
using System;
using System.Linq;
using System.Threading.Tasks;
namespace IntegrationTests
namespace CoreIntegrationTests
{
public class Nested
{
+2 -2
View File
@@ -1,10 +1,10 @@
using IntegrationTests.Infrastructure;
using CoreIntegrationTests.Infrastructure;
using MongoDbGenericRepository.Models;
using Xunit;
using System;
using System.Threading.Tasks;
namespace IntegrationTests
namespace CoreIntegrationTests
{
public class ReadTestsPartitionedDocument : PartitionedDocument
{
+2 -2
View File
@@ -1,10 +1,10 @@
using IntegrationTests.Infrastructure;
using CoreIntegrationTests.Infrastructure;
using MongoDbGenericRepository.Models;
using Xunit;
using System;
using System.Threading.Tasks;
namespace IntegrationTests
namespace CoreIntegrationTests
{
public class ReadTestsDocument : Document
{
@@ -1,9 +1,9 @@
using IntegrationTests.Infrastructure;
using CoreIntegrationTests.Infrastructure;
using MongoDbGenericRepository.Models;
using Xunit;
using System.Threading.Tasks;
namespace IntegrationTests
namespace CoreIntegrationTests
{
public class UpdateTestsPartitionedDocument : PartitionedDocument
{
+2 -2
View File
@@ -1,9 +1,9 @@
using IntegrationTests.Infrastructure;
using CoreIntegrationTests.Infrastructure;
using MongoDbGenericRepository.Models;
using Xunit;
using System.Threading.Tasks;
namespace IntegrationTests
namespace CoreIntegrationTests
{
public class UpdateTestsDocument : Document
{
@@ -900,6 +900,15 @@ namespace MongoDbGenericRepository
MongoDbContext = mongoDbContext;
}
/// <summary>
/// The contructor taking a <see cref="IMongoDatabase"/>.
/// </summary>
/// <param name="mongoDatabase">A mongodb context implementing <see cref="IMongoDatabase"/></param>
protected BaseMongoRepository(IMongoDatabase mongoDatabase)
{
MongoDbContext = new MongoDbContext(mongoDatabase);
}
/// <summary>
/// The MongoDbContext
/// </summary>
@@ -2009,6 +2018,7 @@ namespace MongoDbGenericRepository
}
/// <summary>
/// Groups filtered a collection of documents given a grouping criteria,
/// and returns a dictionary of listed document groups with keys having the different values of the grouping criteria.
/// </summary>
@@ -53,5 +53,11 @@ namespace MongoDbGenericRepository
/// </summary>
/// <typeparam name="TDocument"></typeparam>
void DropCollection<TDocument>(string partitionKey);
/// <summary>
/// Sets the Guid representation of the MongoDb Driver.
/// </summary>
/// <param name="guidRepresentation">The new value of the GuidRepresentation</param>
void SetGuidRepresentation(MongoDB.Bson.GuidRepresentation guidRepresentation);
}
}
@@ -25,6 +25,15 @@ namespace MongoDbGenericRepository
MongoDefaults.GuidRepresentation = MongoDB.Bson.GuidRepresentation.Standard;
}
/// <summary>
/// Sets the Guid representation of the MongoDb Driver.
/// </summary>
/// <param name="guidRepresentation">The new value of the GuidRepresentation</param>
public void SetGuidRepresentation(MongoDB.Bson.GuidRepresentation guidRepresentation)
{
MongoDefaults.GuidRepresentation = guidRepresentation;
}
/// <summary>
/// The constructor of the MongoDbContext, it needs a an object implementing <see cref="IMongoDatabase"/>.
/// </summary>