Skip to content

feat: upgrade package MongoDB.Driver to version 3.3.0 only in netstandard2.1 #65

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion MongoDbGenericRepository/DataAccess/Base/DataAccessBase.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using MongoDB.Driver;
using MongoDB.Driver.Linq;
using MongoDbGenericRepository.Models;
using System;
using System.Linq.Expressions;

namespace MongoDbGenericRepository.DataAccess.Base
Expand Down Expand Up @@ -35,12 +34,22 @@ public DataAccessBase(IMongoDbContext mongoDbContext)
/// <param name="filter">The filter definition.</param>
/// <param name="partitionKey">The collection partition key.</param>
/// <returns></returns>
#if NETSTANDARD2_0 || NET472
public virtual IMongoQueryable<TDocument> GetQuery<TDocument, TKey>(Expression<Func<TDocument, bool>> filter, string partitionKey = null)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
return GetCollection<TDocument, TKey>(partitionKey).AsQueryable().Where(filter);
}
#endif
#if NETSTANDARD2_1_OR_GREATER
public virtual IQueryable<TDocument> GetQuery<TDocument, TKey>(Expression<Func<TDocument, bool>> filter, string partitionKey = null)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
return GetCollection<TDocument, TKey>(partitionKey).AsQueryable().Where(filter);
}
#endif

/// <summary>
/// Gets a collections for a potentially partitioned document type.
Expand Down
9 changes: 7 additions & 2 deletions MongoDbGenericRepository/DataAccess/Base/IDataAccessBase.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
using System;
using System.Linq.Expressions;
using MongoDB.Driver;
using MongoDB.Driver.Linq;
using MongoDbGenericRepository.Models;
using System.Linq.Expressions;

namespace MongoDbGenericRepository.DataAccess.Base
{
Expand All @@ -19,9 +18,15 @@ public interface IDataAccessBase
/// <param name="filter">The filter definition.</param>
/// <param name="partitionKey">The collection partition key.</param>
/// <returns></returns>
#if NETSTANDARD2_0 || NET472
IMongoQueryable<TDocument> GetQuery<TDocument, TKey>(Expression<Func<TDocument, bool>> filter, string partitionKey = null)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
#elif NETSTANDARD2_1_OR_GREATER
IQueryable<TDocument> GetQuery<TDocument, TKey>(Expression<Func<TDocument, bool>> filter, string partitionKey = null)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
#endif

/// <summary>
/// Gets a collections for a potentially partitioned document type.
Expand Down
2 changes: 2 additions & 0 deletions MongoDbGenericRepository/MongoDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ public virtual void SetGuidRepresentation(GuidRepresentation guidRepresentation)
// GuidRepresentation and GuidRepresentationMode will be removed in the next major release of the MongoDB Driver.
// We can safely replace this with RepositorySerializationProvider.Instance.RegisterSerializer once we upgrade to the next major release.
#pragma warning disable CS0618
#if NETSTANDARD2_0 || NET472
BsonDefaults.GuidRepresentationMode = GuidRepresentationMode.V3;
#endif
RepositorySerializationProvider.Instance.RegisterSerializer(new GuidSerializer(guidRepresentation));
#pragma warning restore CS0618
}
Expand Down
9 changes: 8 additions & 1 deletion MongoDbGenericRepository/MongoDbGenericRepository.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,14 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="MongoDB.Driver" Version="[2.30.0,3)" />
<None Include="..\README.md" Pack="true" PackagePath="\" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net472' or '$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="MongoDB.Driver" Version="[2.30.0,3)" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.1'">
<PackageReference Include="MongoDB.Driver" Version="[3.*,)" />
</ItemGroup>
</Project>