The MongoDbRepository now has a constructor that takes an IMongoDatabase.
This commit is contained in:
@@ -1,10 +1,10 @@
|
|||||||
using IntegrationTests.Infrastructure;
|
using CoreIntegrationTests.Infrastructure;
|
||||||
using MongoDbGenericRepository.Models;
|
using MongoDbGenericRepository.Models;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace IntegrationTests
|
namespace CoreIntegrationTests
|
||||||
{
|
{
|
||||||
public class CreateTestsPartitionedDocument : PartitionedDocument
|
public class CreateTestsPartitionedDocument : PartitionedDocument
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
using IntegrationTests.Infrastructure;
|
using CoreIntegrationTests.Infrastructure;
|
||||||
using MongoDbGenericRepository.Models;
|
using MongoDbGenericRepository.Models;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace IntegrationTests
|
namespace CoreIntegrationTests
|
||||||
{
|
{
|
||||||
public class CreateTestsDocument : Document
|
public class CreateTestsDocument : Document
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
using IntegrationTests.Infrastructure;
|
using CoreIntegrationTests.Infrastructure;
|
||||||
using MongoDbGenericRepository.Models;
|
using MongoDbGenericRepository.Models;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace IntegrationTests
|
namespace CoreIntegrationTests
|
||||||
{
|
{
|
||||||
public class DeleteTestsPartitionedDocument : PartitionedDocument
|
public class DeleteTestsPartitionedDocument : PartitionedDocument
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
using IntegrationTests.Infrastructure;
|
using CoreIntegrationTests.Infrastructure;
|
||||||
using MongoDbGenericRepository.Models;
|
using MongoDbGenericRepository.Models;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace IntegrationTests
|
namespace CoreIntegrationTests
|
||||||
{
|
{
|
||||||
public class DeleteTestsDocument : Document
|
public class DeleteTestsDocument : Document
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,14 +1,12 @@
|
|||||||
using IntegrationTests.Infrastructure;
|
using CoreIntegrationTests.Infrastructure;
|
||||||
using MongoDB.Bson.Serialization.Attributes;
|
|
||||||
using MongoDbGenericRepository.Models;
|
using MongoDbGenericRepository.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
|
||||||
using Xunit;
|
using Xunit;
|
||||||
using Microsoft.AspNetCore.Identity;
|
using Microsoft.AspNetCore.Identity;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace CoreIntegrationTests
|
namespace CoreCoreIntegrationTests
|
||||||
{
|
{
|
||||||
public class MongoIdentityUser<TKey> : IdentityUser<TKey>, IDocument<TKey>
|
public class MongoIdentityUser<TKey> : IdentityUser<TKey>, IDocument<TKey>
|
||||||
where TKey : IEquatable<TKey>
|
where TKey : IEquatable<TKey>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace IntegrationTests.Infrastructure
|
namespace CoreIntegrationTests.Infrastructure
|
||||||
{
|
{
|
||||||
|
|
||||||
public class BaseMongoDbRepositoryTests<T> : IDisposable where T : new()
|
public class BaseMongoDbRepositoryTests<T> : IDisposable where T : new()
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
using MongoDbGenericRepository;
|
using MongoDbGenericRepository;
|
||||||
|
|
||||||
namespace IntegrationTests
|
namespace CoreIntegrationTests
|
||||||
{
|
{
|
||||||
public interface ITestRepository : IBaseMongoRepository
|
public interface ITestRepository : IBaseMongoRepository
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
using CoreIntegrationTests;
|
using CoreCoreIntegrationTests;
|
||||||
using MongoDB.Bson.Serialization;
|
using MongoDB.Bson.Serialization;
|
||||||
using MongoDB.Bson.Serialization.Conventions;
|
using MongoDB.Bson.Serialization.Conventions;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
|
||||||
namespace IntegrationTests.Infrastructure
|
namespace CoreIntegrationTests.Infrastructure
|
||||||
{
|
{
|
||||||
internal static class MongoDbConfig
|
internal static class MongoDbConfig
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
using MongoDbGenericRepository;
|
using MongoDbGenericRepository;
|
||||||
|
|
||||||
namespace IntegrationTests.Infrastructure
|
namespace CoreIntegrationTests.Infrastructure
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A singleton implementation of the TestRepository
|
/// A singleton implementation of the TestRepository
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
using IntegrationTests.Infrastructure;
|
using CoreIntegrationTests.Infrastructure;
|
||||||
using MongoDbGenericRepository.Models;
|
using MongoDbGenericRepository.Models;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace IntegrationTests
|
namespace CoreIntegrationTests
|
||||||
{
|
{
|
||||||
public class ProjectTestsPartitionedDocument : PartitionedDocument
|
public class ProjectTestsPartitionedDocument : PartitionedDocument
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
using IntegrationTests.Infrastructure;
|
using CoreIntegrationTests.Infrastructure;
|
||||||
using MongoDbGenericRepository.Models;
|
using MongoDbGenericRepository.Models;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace IntegrationTests
|
namespace CoreIntegrationTests
|
||||||
{
|
{
|
||||||
public class Nested
|
public class Nested
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
using IntegrationTests.Infrastructure;
|
using CoreIntegrationTests.Infrastructure;
|
||||||
using MongoDbGenericRepository.Models;
|
using MongoDbGenericRepository.Models;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
using System;
|
using System;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace IntegrationTests
|
namespace CoreIntegrationTests
|
||||||
{
|
{
|
||||||
public class ReadTestsPartitionedDocument : PartitionedDocument
|
public class ReadTestsPartitionedDocument : PartitionedDocument
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
using IntegrationTests.Infrastructure;
|
using CoreIntegrationTests.Infrastructure;
|
||||||
using MongoDbGenericRepository.Models;
|
using MongoDbGenericRepository.Models;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
using System;
|
using System;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace IntegrationTests
|
namespace CoreIntegrationTests
|
||||||
{
|
{
|
||||||
public class ReadTestsDocument : Document
|
public class ReadTestsDocument : Document
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
using IntegrationTests.Infrastructure;
|
using CoreIntegrationTests.Infrastructure;
|
||||||
using MongoDbGenericRepository.Models;
|
using MongoDbGenericRepository.Models;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace IntegrationTests
|
namespace CoreIntegrationTests
|
||||||
{
|
{
|
||||||
public class UpdateTestsPartitionedDocument : PartitionedDocument
|
public class UpdateTestsPartitionedDocument : PartitionedDocument
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
using IntegrationTests.Infrastructure;
|
using CoreIntegrationTests.Infrastructure;
|
||||||
using MongoDbGenericRepository.Models;
|
using MongoDbGenericRepository.Models;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace IntegrationTests
|
namespace CoreIntegrationTests
|
||||||
{
|
{
|
||||||
public class UpdateTestsDocument : Document
|
public class UpdateTestsDocument : Document
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -900,6 +900,15 @@ namespace MongoDbGenericRepository
|
|||||||
MongoDbContext = mongoDbContext;
|
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>
|
/// <summary>
|
||||||
/// The MongoDbContext
|
/// The MongoDbContext
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -2009,6 +2018,7 @@ namespace MongoDbGenericRepository
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
/// Groups filtered a collection of documents given a grouping criteria,
|
/// 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.
|
/// and returns a dictionary of listed document groups with keys having the different values of the grouping criteria.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -53,5 +53,11 @@ namespace MongoDbGenericRepository
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TDocument"></typeparam>
|
/// <typeparam name="TDocument"></typeparam>
|
||||||
void DropCollection<TDocument>(string partitionKey);
|
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;
|
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>
|
/// <summary>
|
||||||
/// The constructor of the MongoDbContext, it needs a an object implementing <see cref="IMongoDatabase"/>.
|
/// The constructor of the MongoDbContext, it needs a an object implementing <see cref="IMongoDatabase"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user