diff --git a/IntegrationTests/IntegrationTests.csproj b/IntegrationTests/IntegrationTests.csproj index 47b9de0..65d3b75 100644 --- a/IntegrationTests/IntegrationTests.csproj +++ b/IntegrationTests/IntegrationTests.csproj @@ -30,35 +30,22 @@ 4 - - ..\packages\MongoDbGenericRepository.1.3.6\lib\net45\DnsClient.dll + + ..\packages\MongoDB.Bson.2.7.0\lib\net45\MongoDB.Bson.dll - - ..\packages\MongoDbGenericRepository.1.3.6\lib\net45\MongoDB.Bson.dll + + ..\packages\MongoDB.Driver.2.7.0\lib\net45\MongoDB.Driver.dll - - ..\packages\MongoDbGenericRepository.1.3.6\lib\net45\MongoDB.Driver.dll - - - ..\packages\MongoDbGenericRepository.1.3.6\lib\net45\MongoDB.Driver.Core.dll - - - ..\packages\MongoDbGenericRepository.1.3.6\lib\net45\MongoDbGenericRepository.dll + + ..\packages\MongoDB.Driver.Core.2.7.0\lib\net45\MongoDB.Driver.Core.dll ..\packages\NUnit.3.9.0\lib\net45\nunit.framework.dll - - ..\packages\MongoDbGenericRepository.1.3.6\lib\net45\System.Buffers.dll - - - ..\packages\MongoDbGenericRepository.1.3.6\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll - True - @@ -87,5 +74,11 @@ + + + {efc776c4-2af3-440c-be80-3fbe335817a5} + MongoDbGenericRepository + + \ No newline at end of file diff --git a/IntegrationTests/packages.config b/IntegrationTests/packages.config index 3891bf8..af7ff01 100644 --- a/IntegrationTests/packages.config +++ b/IntegrationTests/packages.config @@ -1,10 +1,9 @@  - - - - + + + diff --git a/MongoDbGenericRepository/BaseMongoDbRepository.cs b/MongoDbGenericRepository/BaseMongoDbRepository.cs index d6dc091..39cec90 100644 --- a/MongoDbGenericRepository/BaseMongoDbRepository.cs +++ b/MongoDbGenericRepository/BaseMongoDbRepository.cs @@ -183,7 +183,18 @@ namespace MongoDbGenericRepository { FormatDocument(document); } - HandlePartitioned(documents.FirstOrDefault()).InsertMany(documents.ToList()); + // cannot use typeof(IPartitionedDocument).IsAssignableFrom(typeof(TDocument)), not available in netstandard 1.5 + if (documents.Any(e => e is IPartitionedDocument)) + { + foreach (var group in documents.GroupBy(e => ((IPartitionedDocument)e).PartitionKey)) + { + HandlePartitioned(group.FirstOrDefault()).InsertMany(group.ToList()); + } + } + else + { + GetCollection().InsertMany(documents.ToList()); + } }