remove default option: IsUpset = true in update methods, to avoid unexpected document insertions.
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
<PackageReference Include="Microsoft.AspNetCore.Identity" Version="2.1.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="2.1.2" />
|
||||
<PackageReference Include="MongoDB.Driver" Version="2.9.3" />
|
||||
<PackageReference Include="MongoDbGenericRepository" Version="1.4.4" />
|
||||
<PackageReference Include="MongoDbGenericRepository" Version="1.4.5" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
<PackageReference Include="xunit.runner.console" Version="2.4.1">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
|
||||
@@ -49,8 +49,8 @@
|
||||
<Reference Include="MongoDB.Driver.Core, Version=2.9.3.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\MongoDB.Driver.Core.2.9.3\lib\net452\MongoDB.Driver.Core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="MongoDbGenericRepository, Version=1.4.4.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\MongoDbGenericRepository.1.4.4\lib\net452\MongoDbGenericRepository.dll</HintPath>
|
||||
<Reference Include="MongoDbGenericRepository, Version=1.4.5.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\MongoDbGenericRepository.1.4.5\lib\net452\MongoDbGenericRepository.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="nunit.framework, Version=3.12.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NUnit.3.12.0\lib\net45\nunit.framework.dll</HintPath>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<package id="MongoDB.Bson" version="2.9.3" targetFramework="net461" />
|
||||
<package id="MongoDB.Driver" version="2.9.3" targetFramework="net461" />
|
||||
<package id="MongoDB.Driver.Core" version="2.9.3" targetFramework="net461" />
|
||||
<package id="MongoDbGenericRepository" version="1.4.4" targetFramework="net461" />
|
||||
<package id="MongoDbGenericRepository" version="1.4.5" targetFramework="net461" />
|
||||
<package id="NUnit" version="3.12.0" targetFramework="net461" />
|
||||
<package id="NUnit.ConsoleRunner" version="3.10.0" targetFramework="net461" />
|
||||
<package id="NUnit3TestAdapter" version="3.15.1" targetFramework="net461" />
|
||||
|
||||
@@ -62,7 +62,7 @@ namespace MongoDbGenericRepository.DataAccess.Update
|
||||
where TKey : IEquatable<TKey>
|
||||
{
|
||||
var filter = Builders<TDocument>.Filter.Eq("Id", documentToModify.Id);
|
||||
var updateRes = await HandlePartitioned<TDocument, TKey>(documentToModify).UpdateOneAsync(session, filter, update, new UpdateOptions { IsUpsert = true }, cancellationToken).ConfigureAwait(false);
|
||||
var updateRes = await HandlePartitioned<TDocument, TKey>(documentToModify).UpdateOneAsync(session, filter, update, null, cancellationToken).ConfigureAwait(false);
|
||||
return updateRes.ModifiedCount == 1;
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ namespace MongoDbGenericRepository.DataAccess.Update
|
||||
where TKey : IEquatable<TKey>
|
||||
{
|
||||
var filter = Builders<TDocument>.Filter.Eq("Id", documentToModify.Id);
|
||||
var updateRes = HandlePartitioned<TDocument, TKey>(documentToModify).UpdateOne(session, filter, update, new UpdateOptions { IsUpsert = true }, cancellationToken);
|
||||
var updateRes = HandlePartitioned<TDocument, TKey>(documentToModify).UpdateOne(session, filter, update, null, cancellationToken);
|
||||
return updateRes.ModifiedCount == 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace MongoDbGenericRepository.DataAccess.Update
|
||||
where TKey : IEquatable<TKey>
|
||||
{
|
||||
var filter = Builders<TDocument>.Filter.Eq("Id", documentToModify.Id);
|
||||
var updateRes = await HandlePartitioned<TDocument, TKey>(documentToModify).UpdateOneAsync(filter, update, new UpdateOptions { IsUpsert = true });
|
||||
var updateRes = await HandlePartitioned<TDocument, TKey>(documentToModify).UpdateOneAsync(filter, update);
|
||||
return updateRes.ModifiedCount == 1;
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ namespace MongoDbGenericRepository.DataAccess.Update
|
||||
where TKey : IEquatable<TKey>
|
||||
{
|
||||
var filter = Builders<TDocument>.Filter.Eq("Id", documentToModify.Id);
|
||||
var updateRes = HandlePartitioned<TDocument, TKey>(documentToModify).UpdateOne(filter, update, new UpdateOptions { IsUpsert = true });
|
||||
var updateRes = HandlePartitioned<TDocument, TKey>(documentToModify).UpdateOne(filter, update);
|
||||
return updateRes.ModifiedCount == 1;
|
||||
}
|
||||
|
||||
@@ -250,7 +250,7 @@ namespace MongoDbGenericRepository.DataAccess.Update
|
||||
where TKey : IEquatable<TKey>
|
||||
{
|
||||
var collection = string.IsNullOrEmpty(partitionKey) ? GetCollection<TDocument, TKey>() : GetCollection<TDocument, TKey>(partitionKey);
|
||||
var updateRes = await collection.UpdateManyAsync(filter, updateDefinition, new UpdateOptions { IsUpsert = true });
|
||||
var updateRes = await collection.UpdateManyAsync(filter, updateDefinition);
|
||||
return updateRes.ModifiedCount;
|
||||
}
|
||||
|
||||
@@ -304,7 +304,7 @@ namespace MongoDbGenericRepository.DataAccess.Update
|
||||
where TKey : IEquatable<TKey>
|
||||
{
|
||||
var collection = string.IsNullOrEmpty(partitionKey) ? GetCollection<TDocument, TKey>() : GetCollection<TDocument, TKey>(partitionKey);
|
||||
var updateRes = collection.UpdateMany(filter, UpdateDefinition, new UpdateOptions { IsUpsert = true });
|
||||
var updateRes = collection.UpdateMany(filter, UpdateDefinition);
|
||||
return updateRes.ModifiedCount;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net452;netstandard2.0;netstandard1.5;</TargetFrameworks>
|
||||
<PackageId>MongoDbGenericRepository</PackageId>
|
||||
<PackageVersion>1.4.4</PackageVersion>
|
||||
<PackageVersion>1.4.5</PackageVersion>
|
||||
<Authors>Alexandre Spieser</Authors>
|
||||
<PackageTitle>MongoDb Generic Repository</PackageTitle>
|
||||
<Description>A generic repository implementation using the MongoDB C# Sharp 2.0 driver.</Description>
|
||||
@@ -14,7 +14,7 @@
|
||||
<Copyright>Copyright 2020 (c) Alexandre Spieser. All rights reserved.</Copyright>
|
||||
<PackageTags>MongoDb Repository Generic NoSql</PackageTags>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
<Version>1.4.4</Version>
|
||||
<Version>1.4.5</Version>
|
||||
<RepositoryUrl>https://github.com/alexandre-spieser/mongodb-generic-repository</RepositoryUrl>
|
||||
<RepositoryType>Git</RepositoryType>
|
||||
</PropertyGroup>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<package >
|
||||
<metadata>
|
||||
<id>MongoDbGenericRepository</id>
|
||||
<version>1.4.4</version>
|
||||
<version>1.4.5</version>
|
||||
<title>MongoDb Generic Repository</title>
|
||||
<authors>Alexandre Spieser</authors>
|
||||
<owners>Alexandre Spieser</owners>
|
||||
|
||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user