Compare commits

..

6 Commits

Author SHA1 Message Date
alexandre-spieser 345fca2e6e Added summary where needed. 2018-03-06 23:11:33 +00:00
alexandre-spieser 57d332ef2a Add support for ObjectId type for the Id of the document. 2018-03-05 23:07:56 +00:00
Alexandre SPIESER 2f6515a809 Merge pull request #3 from alexandre-spieser/add-license-1
Create LICENSE
2018-02-24 12:22:58 +00:00
Alexandre SPIESER 82dc2f2024 Create LICENSE 2018-02-24 12:22:49 +00:00
Alexandre SPIESER bc992e8c61 Update README.md 2018-02-16 15:11:09 +00:00
Alexandre SPIESER 47e85f1760 Update README.md 2018-02-16 15:10:18 +00:00
20 changed files with 225 additions and 73 deletions
+22
View File
@@ -0,0 +1,22 @@
using CoreIntegrationTests.Infrastructure;
using MongoDB.Bson;
using System;
namespace CoreIntegrationTests
{
public class CoreObjectIdTestDocument : TestDoc<ObjectId>
{
}
public class CRUDObjectIdTests : MongoDbTKeyDocumentTestBase<CoreObjectIdTestDocument, ObjectId>
{
public CRUDObjectIdTests(MongoDbTestFixture<CoreObjectIdTestDocument, ObjectId> fixture) : base(fixture)
{
}
public override string GetClassName()
{
return "CRUDObjectIdTests";
}
}
}
@@ -9,7 +9,7 @@
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="2.0.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" />
<PackageReference Include="MongoDB.Driver" Version="2.5.0" />
<PackageReference Include="MongoDbGenericRepository" Version="1.3.5" />
<PackageReference Include="MongoDbGenericRepository" Version="1.3.6" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.runner.console" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
@@ -1,5 +1,6 @@
using MongoDB.Bson.Serialization.Attributes;
using MongoDbGenericRepository.Models;
using MongoDbGenericRepository.Utils;
using System;
using System.Collections.Generic;
@@ -82,22 +83,7 @@ namespace CoreIntegrationTests.Infrastructure
public TId Init<TId>()
{
var idTypeName = typeof(TKey).Name;
switch (idTypeName)
{
case "Guid":
return (TId)(object)Guid.NewGuid();
case "Int16":
return (TId)(object)GlobalVariables.Random.Next(1, short.MaxValue);
case "Int32":
return (TId)(object)GlobalVariables.Random.Next(1, int.MaxValue);
case "Int64":
return (TId)(object)(GlobalVariables.Random.NextLong(1, long.MaxValue));
case "String":
return (TId)(object)Guid.NewGuid().ToString();
default:
throw new NotSupportedException($"{idTypeName} is not supported.");
}
return IdGenerator.GetId<TId>();
}
private void InitializeFields()
+19
View File
@@ -0,0 +1,19 @@
using IntegrationTests.Infrastructure;
using MongoDB.Bson;
using NUnit.Framework;
namespace IntegrationTests
{
public class ObjectIdTestDocument : TestDoc<ObjectId>
{
}
[TestFixture]
public class CRUDObjectIdTests : MongoDbTKeyDocumentTestBase<ObjectIdTestDocument, ObjectId>
{
public override string GetClassName()
{
return "CRUDObjectIdTests";
}
}
}
+2 -16
View File
@@ -1,5 +1,6 @@
using MongoDB.Bson.Serialization.Attributes;
using MongoDbGenericRepository.Models;
using MongoDbGenericRepository.Utils;
using System;
using System.Collections.Generic;
@@ -82,22 +83,7 @@ namespace IntegrationTests.Infrastructure
public TId Init<TId>()
{
var idTypeName = typeof(TKey).Name;
switch (idTypeName)
{
case "Guid":
return (TId)(object)Guid.NewGuid();
case "Int16":
return (TId)(object)GlobalVariables.Random.Next(1, short.MaxValue);
case "Int32":
return (TId)(object)GlobalVariables.Random.Next(1, int.MaxValue);
case "Int64":
return (TId)(object)(GlobalVariables.Random.NextLong(1, long.MaxValue));
case "String":
return (TId)(object)Guid.NewGuid().ToString();
default:
throw new NotSupportedException($"{idTypeName} is not supported.");
}
return IdGenerator.GetId<TId>();
}
private void InitializeFields()
+8 -7
View File
@@ -31,36 +31,37 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="DnsClient, Version=1.0.7.0, Culture=neutral, PublicKeyToken=4574bb5573c51424, processorArchitecture=MSIL">
<HintPath>..\packages\MongoDbGenericRepository.1.3.5\lib\net45\DnsClient.dll</HintPath>
<HintPath>..\packages\MongoDbGenericRepository.1.3.6\lib\net45\DnsClient.dll</HintPath>
</Reference>
<Reference Include="MongoDB.Bson, Version=2.5.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MongoDbGenericRepository.1.3.5\lib\net45\MongoDB.Bson.dll</HintPath>
<HintPath>..\packages\MongoDbGenericRepository.1.3.6\lib\net45\MongoDB.Bson.dll</HintPath>
</Reference>
<Reference Include="MongoDB.Driver, Version=2.5.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MongoDbGenericRepository.1.3.5\lib\net45\MongoDB.Driver.dll</HintPath>
<HintPath>..\packages\MongoDbGenericRepository.1.3.6\lib\net45\MongoDB.Driver.dll</HintPath>
</Reference>
<Reference Include="MongoDB.Driver.Core, Version=2.5.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MongoDbGenericRepository.1.3.5\lib\net45\MongoDB.Driver.Core.dll</HintPath>
<HintPath>..\packages\MongoDbGenericRepository.1.3.6\lib\net45\MongoDB.Driver.Core.dll</HintPath>
</Reference>
<Reference Include="MongoDbGenericRepository, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MongoDbGenericRepository.1.3.5\lib\net45\MongoDbGenericRepository.dll</HintPath>
<HintPath>..\packages\MongoDbGenericRepository.1.3.6\lib\net45\MongoDbGenericRepository.dll</HintPath>
</Reference>
<Reference Include="nunit.framework, Version=3.9.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<HintPath>..\packages\NUnit.3.9.0\lib\net45\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Buffers, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\MongoDbGenericRepository.1.3.5\lib\net45\System.Buffers.dll</HintPath>
<HintPath>..\packages\MongoDbGenericRepository.1.3.6\lib\net45\System.Buffers.dll</HintPath>
</Reference>
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Runtime.InteropServices.RuntimeInformation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\MongoDbGenericRepository.1.3.5\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll</HintPath>
<HintPath>..\packages\MongoDbGenericRepository.1.3.6\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="CRUDObjectIdTests.cs" />
<Compile Include="CRUDPartitionedTests.cs" />
<Compile Include="CRUDTKeyPartitionedCollectionNameAttributeTests.cs" />
<Compile Include="CRUDTests.cs" />
+1 -1
View File
@@ -4,7 +4,7 @@
<package id="MongoDB.Bson" version="2.5.0" targetFramework="net461" />
<package id="MongoDB.Driver" version="2.5.0" targetFramework="net461" />
<package id="MongoDB.Driver.Core" version="2.5.0" targetFramework="net461" />
<package id="MongoDbGenericRepository" version="1.3.5" targetFramework="net461" />
<package id="MongoDbGenericRepository" version="1.3.6" targetFramework="net461" />
<package id="NUnit" version="3.9.0" targetFramework="net461" />
<package id="NUnit.ConsoleRunner" version="3.7.0" targetFramework="net461" />
<package id="System.Buffers" version="4.3.0" targetFramework="net461" />
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2018 Alexandre SPIESER
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
@@ -167,6 +167,7 @@ namespace MongoDbGenericRepository
/// <param name="filter">The document filter.</param>
/// <param name="field">The field selector.</param>
/// <param name="value">The new value of the property field.</param>
/// <param name="partitionKey">The partition key for the document.</param>
bool UpdateOne<TDocument, TField>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null)
where TDocument : IDocument;
@@ -183,11 +184,11 @@ namespace MongoDbGenericRepository
/// For the entity selected by the filter, updates the property field with the given value.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <typeparam name="TField">The type of the field.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="field">The field selector.</param>
/// <param name="value">The new value of the property field.</param>
/// <param name="partitionKey">The partition key for the document.</param>
Task<bool> UpdateOneAsync<TDocument, TField>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null)
where TDocument : IDocument;
@@ -255,6 +256,7 @@ namespace MongoDbGenericRepository
/// <param name="filter">The document filter.</param>
/// <param name="field">The field selector.</param>
/// <param name="value">The new value of the property field.</param>
/// <param name="partitionKey">The partition key for the document.</param>
bool UpdateOne<TDocument, TKey, TField>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
@@ -281,6 +283,7 @@ namespace MongoDbGenericRepository
/// <param name="filter">The document filter.</param>
/// <param name="field">The field selector.</param>
/// <param name="value">The new value of the property field.</param>
/// <param name="partitionKey">The partition key for the document.</param>
Task<bool> UpdateOneAsync<TDocument, TKey, TField>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
@@ -17,6 +17,10 @@ namespace MongoDbGenericRepository.Attributes
/// </summary>
public string Name { get; set; }
/// <summary>
/// The constructor.
/// </summary>
/// <param name="name">The name of the collection.</param>
public CollectionNameAttribute(string name)
{
this.Name = name;
@@ -15,7 +15,6 @@ namespace MongoDbGenericRepository
/// </summary>
public abstract class BaseMongoRepository : ReadOnlyMongoRepository, IBaseMongoRepository
{
private static readonly Random Random = new Random();
/// <summary>
/// The constructor taking a connection string and a database name.
@@ -285,6 +284,7 @@ namespace MongoDbGenericRepository
/// <param name="filter">The document filter.</param>
/// <param name="field">The field selector.</param>
/// <param name="value">The new value of the property field.</param>
/// <param name="partitionKey">The partition key for the document.</param>
public virtual bool UpdateOne<TDocument, TField>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null)
where TDocument : IDocument
{
@@ -314,11 +314,11 @@ namespace MongoDbGenericRepository
/// For the entity selected by the filter, updates the property field with the given value.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <typeparam name="TField">The type of the field.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="field">The field selector.</param>
/// <param name="value">The new value of the property field.</param>
/// <param name="partitionKey">The partition key for the document.</param>
public virtual async Task<bool> UpdateOneAsync<TDocument, TField>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null)
where TDocument : IDocument
{
@@ -471,6 +471,7 @@ namespace MongoDbGenericRepository
/// <param name="filter">The document filter.</param>
/// <param name="field">The field selector.</param>
/// <param name="value">The new value of the property field.</param>
/// <param name="partitionKey">The partition key for the document.</param>
public virtual async Task<bool> UpdateOneAsync<TDocument, TKey, TField>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
@@ -508,6 +509,7 @@ namespace MongoDbGenericRepository
/// <param name="filter">The document filter.</param>
/// <param name="field">The field selector.</param>
/// <param name="value">The new value of the property field.</param>
/// <param name="partitionKey">The partition key for the document.</param>
public virtual bool UpdateOne<TDocument, TKey, TField>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
@@ -1022,26 +1024,6 @@ namespace MongoDbGenericRepository
#endregion Find And Update
private TKey SetIdField<TKey>()
{
var idTypeName = typeof(TKey).Name;
switch (idTypeName)
{
case "Guid":
return (TKey)(object)Guid.NewGuid();
case "Int16":
return (TKey)(object)Random.Next(1, short.MaxValue);
case "Int32":
return (TKey)(object)Random.Next(1, int.MaxValue);
case "Int64":
return (TKey)(object)(Random.NextLong(1, long.MaxValue));
case "String":
return (TKey)(object)Guid.NewGuid().ToString();
}
throw new ArgumentException($"{idTypeName} is not a supported Id type, the Id of the document cannot be set.");
}
/// <summary>
/// Sets the value of the document Id if it is not set already.
/// </summary>
@@ -1061,7 +1043,7 @@ namespace MongoDbGenericRepository
|| (defaultTKey != null
&& defaultTKey.Equals(document.Id)))
{
document.Id = SetIdField<TKey>();
document.Id = IdGenerator.GetId<TKey>();
}
}
@@ -2,7 +2,7 @@
<package >
<metadata>
<id>MongoDbGenericRepository</id>
<version>1.3.5</version>
<version>1.3.6</version>
<title>MongoDb Generic Repository</title>
<authors>Alexandre Spieser</authors>
<owners>Alexandre Spieser</owners>
@@ -10,7 +10,7 @@
<projectUrl>https://github.com/alexandre-spieser/mongodb-generic-repository</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>A generic repository implementation using the MongoDB C# Sharp 2.0 driver.</description>
<releaseNotes>Adding CollectionName attribute to specify alternate collection name (thanks Etchelon).</releaseNotes>
<releaseNotes>Adding support for Id of type ObjectId.</releaseNotes>
<copyright>Copyright 2017 (c) Alexandre Spieser. All rights reserved.</copyright>
<tags>MongoDb Repository Generic NoSql</tags>
<dependencies>
@@ -0,0 +1,39 @@
using MongoDB.Bson;
using System;
namespace MongoDbGenericRepository.Utils
{
/// <summary>
/// The IdGenerator instance, used to generate Ids of different types.
/// </summary>
public static class IdGenerator
{
private static readonly Random Random = new Random();
/// <summary>
/// Generates a random value of a given type.
/// </summary>
/// <typeparam name="TKey">The type of the value to generate.</typeparam>
/// <returns>A value of type TKey.</returns>
public static TKey GetId<TKey>()
{
var idTypeName = typeof(TKey).Name;
switch (idTypeName)
{
case "Guid":
return (TKey)(object)Guid.NewGuid();
case "Int16":
return (TKey)(object)Random.Next(1, short.MaxValue);
case "Int32":
return (TKey)(object)Random.Next(1, int.MaxValue);
case "Int64":
return (TKey)(object)(Random.NextLong(1, long.MaxValue));
case "String":
return (TKey)(object)Guid.NewGuid().ToString();
case "ObjectId":
return (TKey)(object)ObjectId.GenerateNewId();
}
throw new ArgumentException($"{idTypeName} is not a supported Id type, the Id of the document cannot be set.");
}
}
}
@@ -141,6 +141,7 @@
<param name="filter">The document filter.</param>
<param name="field">The field selector.</param>
<param name="value">The new value of the property field.</param>
<param name="partitionKey">The partition key for the document.</param>
</member>
<member name="M:MongoDbGenericRepository.IBaseMongoRepository.UpdateOneAsync``1(``0,MongoDB.Driver.UpdateDefinition{``0})">
<summary>
@@ -155,11 +156,11 @@
For the entity selected by the filter, updates the property field with the given value.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TKey">The type of the primary key for a Document.</typeparam>
<typeparam name="TField">The type of the field.</typeparam>
<param name="filter">The document filter.</param>
<param name="field">The field selector.</param>
<param name="value">The new value of the property field.</param>
<param name="partitionKey">The partition key for the document.</param>
</member>
<member name="M:MongoDbGenericRepository.IBaseMongoRepository.UpdateOne``1(``0,MongoDB.Driver.UpdateDefinition{``0})">
<summary>
@@ -213,6 +214,7 @@
<param name="filter">The document filter.</param>
<param name="field">The field selector.</param>
<param name="value">The new value of the property field.</param>
<param name="partitionKey">The partition key for the document.</param>
</member>
<member name="M:MongoDbGenericRepository.IBaseMongoRepository.UpdateOneAsync``3(``0,System.Linq.Expressions.Expression{System.Func{``0,``2}},``2)">
<summary>
@@ -235,6 +237,7 @@
<param name="filter">The document filter.</param>
<param name="field">The field selector.</param>
<param name="value">The new value of the property field.</param>
<param name="partitionKey">The partition key for the document.</param>
</member>
<member name="M:MongoDbGenericRepository.IBaseMongoRepository.UpdateOne``3(``0,System.Linq.Expressions.Expression{System.Func{``0,``2}},``2)">
<summary>
@@ -830,6 +833,12 @@
The name of the collection in which your documents are stored.
</summary>
</member>
<member name="M:MongoDbGenericRepository.Attributes.CollectionNameAttribute.#ctor(System.String)">
<summary>
The constructor.
</summary>
<param name="name">The name of the collection.</param>
</member>
<member name="T:MongoDbGenericRepository.BaseMongoRepository">
<summary>
The base Repository, it is meant to be inherited from by your custom custom MongoRepository implementation.
@@ -985,6 +994,7 @@
<param name="filter">The document filter.</param>
<param name="field">The field selector.</param>
<param name="value">The new value of the property field.</param>
<param name="partitionKey">The partition key for the document.</param>
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.UpdateOneAsync``2(MongoDB.Driver.FilterDefinition{``0},System.Linq.Expressions.Expression{System.Func{``0,``1}},``1,System.String)">
<summary>
@@ -1002,11 +1012,11 @@
For the entity selected by the filter, updates the property field with the given value.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TKey">The type of the primary key for a Document.</typeparam>
<typeparam name="TField">The type of the field.</typeparam>
<param name="filter">The document filter.</param>
<param name="field">The field selector.</param>
<param name="value">The new value of the property field.</param>
<param name="partitionKey">The partition key for the document.</param>
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.UpdateOne``1(``0,MongoDB.Driver.UpdateDefinition{``0})">
<summary>
@@ -1094,6 +1104,7 @@
<param name="filter">The document filter.</param>
<param name="field">The field selector.</param>
<param name="value">The new value of the property field.</param>
<param name="partitionKey">The partition key for the document.</param>
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.UpdateOne``3(MongoDB.Driver.FilterDefinition{``0},System.Linq.Expressions.Expression{System.Func{``0,``2}},``2,System.String)">
<summary>
@@ -1117,6 +1128,7 @@
<param name="filter">The document filter.</param>
<param name="field">The field selector.</param>
<param name="value">The new value of the property field.</param>
<param name="partitionKey">The partition key for the document.</param>
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.DeleteOneAsync``1(``0)">
<summary>
@@ -1870,6 +1882,18 @@
<param name="partitionKey">The collection partition key.</param>
<returns></returns>
</member>
<member name="T:MongoDbGenericRepository.Utils.IdGenerator">
<summary>
The IdGenerator instance, used to generate Ids of different types.
</summary>
</member>
<member name="M:MongoDbGenericRepository.Utils.IdGenerator.GetId``1">
<summary>
Generates a random value of a given type.
</summary>
<typeparam name="TKey">The type of the value to generate.</typeparam>
<returns>A value of type TKey.</returns>
</member>
<member name="T:MongoDbGenericRepository.Utils.Vocabularies">
<summary>
Container for registered Vocabularies. At present, only a single vocabulary is supported: Default.
@@ -141,6 +141,7 @@
<param name="filter">The document filter.</param>
<param name="field">The field selector.</param>
<param name="value">The new value of the property field.</param>
<param name="partitionKey">The partition key for the document.</param>
</member>
<member name="M:MongoDbGenericRepository.IBaseMongoRepository.UpdateOneAsync``1(``0,MongoDB.Driver.UpdateDefinition{``0})">
<summary>
@@ -155,11 +156,11 @@
For the entity selected by the filter, updates the property field with the given value.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TKey">The type of the primary key for a Document.</typeparam>
<typeparam name="TField">The type of the field.</typeparam>
<param name="filter">The document filter.</param>
<param name="field">The field selector.</param>
<param name="value">The new value of the property field.</param>
<param name="partitionKey">The partition key for the document.</param>
</member>
<member name="M:MongoDbGenericRepository.IBaseMongoRepository.UpdateOne``1(``0,MongoDB.Driver.UpdateDefinition{``0})">
<summary>
@@ -213,6 +214,7 @@
<param name="filter">The document filter.</param>
<param name="field">The field selector.</param>
<param name="value">The new value of the property field.</param>
<param name="partitionKey">The partition key for the document.</param>
</member>
<member name="M:MongoDbGenericRepository.IBaseMongoRepository.UpdateOneAsync``3(``0,System.Linq.Expressions.Expression{System.Func{``0,``2}},``2)">
<summary>
@@ -235,6 +237,7 @@
<param name="filter">The document filter.</param>
<param name="field">The field selector.</param>
<param name="value">The new value of the property field.</param>
<param name="partitionKey">The partition key for the document.</param>
</member>
<member name="M:MongoDbGenericRepository.IBaseMongoRepository.UpdateOne``3(``0,System.Linq.Expressions.Expression{System.Func{``0,``2}},``2)">
<summary>
@@ -830,6 +833,12 @@
The name of the collection in which your documents are stored.
</summary>
</member>
<member name="M:MongoDbGenericRepository.Attributes.CollectionNameAttribute.#ctor(System.String)">
<summary>
The constructor.
</summary>
<param name="name">The name of the collection.</param>
</member>
<member name="T:MongoDbGenericRepository.BaseMongoRepository">
<summary>
The base Repository, it is meant to be inherited from by your custom custom MongoRepository implementation.
@@ -985,6 +994,7 @@
<param name="filter">The document filter.</param>
<param name="field">The field selector.</param>
<param name="value">The new value of the property field.</param>
<param name="partitionKey">The partition key for the document.</param>
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.UpdateOneAsync``2(MongoDB.Driver.FilterDefinition{``0},System.Linq.Expressions.Expression{System.Func{``0,``1}},``1,System.String)">
<summary>
@@ -1002,11 +1012,11 @@
For the entity selected by the filter, updates the property field with the given value.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TKey">The type of the primary key for a Document.</typeparam>
<typeparam name="TField">The type of the field.</typeparam>
<param name="filter">The document filter.</param>
<param name="field">The field selector.</param>
<param name="value">The new value of the property field.</param>
<param name="partitionKey">The partition key for the document.</param>
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.UpdateOne``1(``0,MongoDB.Driver.UpdateDefinition{``0})">
<summary>
@@ -1094,6 +1104,7 @@
<param name="filter">The document filter.</param>
<param name="field">The field selector.</param>
<param name="value">The new value of the property field.</param>
<param name="partitionKey">The partition key for the document.</param>
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.UpdateOne``3(MongoDB.Driver.FilterDefinition{``0},System.Linq.Expressions.Expression{System.Func{``0,``2}},``2,System.String)">
<summary>
@@ -1117,6 +1128,7 @@
<param name="filter">The document filter.</param>
<param name="field">The field selector.</param>
<param name="value">The new value of the property field.</param>
<param name="partitionKey">The partition key for the document.</param>
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.DeleteOneAsync``1(``0)">
<summary>
@@ -1870,6 +1882,18 @@
<param name="partitionKey">The collection partition key.</param>
<returns></returns>
</member>
<member name="T:MongoDbGenericRepository.Utils.IdGenerator">
<summary>
The IdGenerator instance, used to generate Ids of different types.
</summary>
</member>
<member name="M:MongoDbGenericRepository.Utils.IdGenerator.GetId``1">
<summary>
Generates a random value of a given type.
</summary>
<typeparam name="TKey">The type of the value to generate.</typeparam>
<returns>A value of type TKey.</returns>
</member>
<member name="T:MongoDbGenericRepository.Utils.Vocabularies">
<summary>
Container for registered Vocabularies. At present, only a single vocabulary is supported: Default.
@@ -141,6 +141,7 @@
<param name="filter">The document filter.</param>
<param name="field">The field selector.</param>
<param name="value">The new value of the property field.</param>
<param name="partitionKey">The partition key for the document.</param>
</member>
<member name="M:MongoDbGenericRepository.IBaseMongoRepository.UpdateOneAsync``1(``0,MongoDB.Driver.UpdateDefinition{``0})">
<summary>
@@ -155,11 +156,11 @@
For the entity selected by the filter, updates the property field with the given value.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TKey">The type of the primary key for a Document.</typeparam>
<typeparam name="TField">The type of the field.</typeparam>
<param name="filter">The document filter.</param>
<param name="field">The field selector.</param>
<param name="value">The new value of the property field.</param>
<param name="partitionKey">The partition key for the document.</param>
</member>
<member name="M:MongoDbGenericRepository.IBaseMongoRepository.UpdateOne``1(``0,MongoDB.Driver.UpdateDefinition{``0})">
<summary>
@@ -213,6 +214,7 @@
<param name="filter">The document filter.</param>
<param name="field">The field selector.</param>
<param name="value">The new value of the property field.</param>
<param name="partitionKey">The partition key for the document.</param>
</member>
<member name="M:MongoDbGenericRepository.IBaseMongoRepository.UpdateOneAsync``3(``0,System.Linq.Expressions.Expression{System.Func{``0,``2}},``2)">
<summary>
@@ -235,6 +237,7 @@
<param name="filter">The document filter.</param>
<param name="field">The field selector.</param>
<param name="value">The new value of the property field.</param>
<param name="partitionKey">The partition key for the document.</param>
</member>
<member name="M:MongoDbGenericRepository.IBaseMongoRepository.UpdateOne``3(``0,System.Linq.Expressions.Expression{System.Func{``0,``2}},``2)">
<summary>
@@ -830,6 +833,12 @@
The name of the collection in which your documents are stored.
</summary>
</member>
<member name="M:MongoDbGenericRepository.Attributes.CollectionNameAttribute.#ctor(System.String)">
<summary>
The constructor.
</summary>
<param name="name">The name of the collection.</param>
</member>
<member name="T:MongoDbGenericRepository.BaseMongoRepository">
<summary>
The base Repository, it is meant to be inherited from by your custom custom MongoRepository implementation.
@@ -985,6 +994,7 @@
<param name="filter">The document filter.</param>
<param name="field">The field selector.</param>
<param name="value">The new value of the property field.</param>
<param name="partitionKey">The partition key for the document.</param>
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.UpdateOneAsync``2(MongoDB.Driver.FilterDefinition{``0},System.Linq.Expressions.Expression{System.Func{``0,``1}},``1,System.String)">
<summary>
@@ -1002,11 +1012,11 @@
For the entity selected by the filter, updates the property field with the given value.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TKey">The type of the primary key for a Document.</typeparam>
<typeparam name="TField">The type of the field.</typeparam>
<param name="filter">The document filter.</param>
<param name="field">The field selector.</param>
<param name="value">The new value of the property field.</param>
<param name="partitionKey">The partition key for the document.</param>
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.UpdateOne``1(``0,MongoDB.Driver.UpdateDefinition{``0})">
<summary>
@@ -1094,6 +1104,7 @@
<param name="filter">The document filter.</param>
<param name="field">The field selector.</param>
<param name="value">The new value of the property field.</param>
<param name="partitionKey">The partition key for the document.</param>
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.UpdateOne``3(MongoDB.Driver.FilterDefinition{``0},System.Linq.Expressions.Expression{System.Func{``0,``2}},``2,System.String)">
<summary>
@@ -1117,6 +1128,7 @@
<param name="filter">The document filter.</param>
<param name="field">The field selector.</param>
<param name="value">The new value of the property field.</param>
<param name="partitionKey">The partition key for the document.</param>
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.DeleteOneAsync``1(``0)">
<summary>
@@ -1870,6 +1882,18 @@
<param name="partitionKey">The collection partition key.</param>
<returns></returns>
</member>
<member name="T:MongoDbGenericRepository.Utils.IdGenerator">
<summary>
The IdGenerator instance, used to generate Ids of different types.
</summary>
</member>
<member name="M:MongoDbGenericRepository.Utils.IdGenerator.GetId``1">
<summary>
Generates a random value of a given type.
</summary>
<typeparam name="TKey">The type of the value to generate.</typeparam>
<returns>A value of type TKey.</returns>
</member>
<member name="T:MongoDbGenericRepository.Utils.Vocabularies">
<summary>
Container for registered Vocabularies. At present, only a single vocabulary is supported: Default.
+17
View File
@@ -40,6 +40,7 @@ Here is an example of repository usage, where the TestRepository is implementing
}
}
```
## Instantiation
The repository can be instantiated like so:
@@ -127,6 +128,22 @@ _testRepository.AddOne(myDoc);
The above code will generate a collection named `myPartitionKey-myPartitionedDocuments`.
## CollectionName Attribute
It is now possible to change the collection name by using the `CollectionName` attribute:
```csharp
[CollectionName("MyCollectionName")]
public class MyDocument : Document
{
public MyDocument()
{
Version = 2;
}
public string SomeContent { get; set; }
}
```
Documents of this type will be inserted into a collection named "MyCollectionName".
Please refer to the IntegrationTests (NET45) and CoreIntegrationTests (netstandard2.0) projects for more usage examples.
## Author