Skip to content
This repository was archived by the owner on Feb 22, 2020. It is now read-only.

.net45 update to use 2.4.4 mongo db driver #53

Open
wants to merge 5 commits 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
3 changes: 0 additions & 3 deletions MongoRepository/CollectionName.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
namespace MongoRepository
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

/// <summary>
/// Attribute used to annotate Enities with to override mongo collection name. By default, when this attribute
Expand Down
159 changes: 84 additions & 75 deletions MongoRepository/MongoRepository.Net45.csproj
Original file line number Diff line number Diff line change
@@ -1,82 +1,91 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{CE75B2FE-C027-42F6-8D00-E44CC38BE7C7}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>MongoRepository</RootNamespace>
<AssemblyName>MongoRepository.Net45</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SccProjectName>SAK</SccProjectName>
<SccLocalPath>SAK</SccLocalPath>
<SccAuxPath>SAK</SccAuxPath>
<SccProvider>SAK</SccProvider>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\MongoRepository\</SolutionDir>
<RestorePackages>true</RestorePackages>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>
</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Release\MongoRepository.Net45.xml</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="MongoDB.Bson, Version=1.11.0.92, Culture=neutral, PublicKeyToken=f686731cfb9cc103, processorArchitecture=MSIL">
<HintPath>..\packages\mongocsharpdriver.1.11.0\lib\net35\MongoDB.Bson.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="MongoDB.Driver, Version=1.11.0.92, Culture=neutral, PublicKeyToken=f686731cfb9cc103, processorArchitecture=MSIL">
<HintPath>..\packages\mongocsharpdriver.1.11.0\lib\net35\MongoDB.Driver.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Data" />
<Reference Include="System.Runtime.Serialization" />
</ItemGroup>
<ItemGroup>
<Compile Include="CollectionName.cs" />
<Compile Include="Entity.cs" />
<Compile Include="IEntity.cs" />
<Compile Include="RepositoryManager\IRepositoryManager.cs" />
<Compile Include="RepositoryManager\MongoRepositoryManager.cs" />
<Compile Include="Repository\IRepository.cs" />
<Compile Include="Repository\MongoRepository.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Util.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config.transform" />
<None Include="packages.config" />
<None Include="web.config.transform" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{CE75B2FE-C027-42F6-8D00-E44CC38BE7C7}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>MongoRepository</RootNamespace>
<AssemblyName>MongoRepository.Net45</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SccProjectName>SAK</SccProjectName>
<SccLocalPath>SAK</SccLocalPath>
<SccAuxPath>SAK</SccAuxPath>
<SccProvider>SAK</SccProvider>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\MongoRepository\</SolutionDir>
<RestorePackages>true</RestorePackages>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>
</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Release\MongoRepository.Net45.xml</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="MongoDB.Bson, Version=2.4.3.23, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MongoDB.Bson.2.4.3\lib\net45\MongoDB.Bson.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="MongoDB.Driver, Version=2.4.3.23, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MongoDB.Driver.2.4.3\lib\net45\MongoDB.Driver.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="MongoDB.Driver.Core, Version=2.4.3.23, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MongoDB.Driver.Core.2.4.3\lib\net45\MongoDB.Driver.Core.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="MongoDB.Driver.Legacy, Version=2.4.3.23, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\mongocsharpdriver.2.4.3\lib\net45\MongoDB.Driver.Legacy.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Data" />
<Reference Include="System.Runtime.Serialization" />
</ItemGroup>
<ItemGroup>
<Compile Include="CollectionName.cs" />
<Compile Include="Entity.cs" />
<Compile Include="IEntity.cs" />
<Compile Include="RepositoryManager\IRepositoryManager.cs" />
<Compile Include="RepositoryManager\MongoRepositoryManager.cs" />
<Compile Include="Repository\IRepository.cs" />
<Compile Include="Repository\MongoRepository.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Util.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config.transform" />
<None Include="packages.config" />
<None Include="web.config.transform" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
-->
</Project>
1 change: 0 additions & 1 deletion MongoRepository/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
Expand Down
31 changes: 1 addition & 30 deletions MongoRepository/Repository/IRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using MongoDB.Bson;
using MongoDB.Driver;

/// <summary>
Expand Down Expand Up @@ -95,35 +94,7 @@ public interface IRepository<T, TKey> : IQueryable<T>
/// <returns>True when an entity matching the predicate exists, false otherwise.</returns>
bool Exists(Expression<Func<T, bool>> predicate);

/// <summary>
/// Lets the server know that this thread is about to begin a series of related operations that must all occur
/// on the same connection. The return value of this method implements IDisposable and can be placed in a using
/// statement (in which case RequestDone will be called automatically when leaving the using statement).
/// </summary>
/// <returns>A helper object that implements IDisposable and calls RequestDone() from the Dispose method.</returns>
/// <remarks>
/// Sometimes a series of operations needs to be performed on the same connection in order to guarantee correct
/// results. This is rarely the case, and most of the time there is no need to call RequestStart/RequestDone.
/// An example of when this might be necessary is when a series of Inserts are called in rapid succession with
/// SafeMode off, and you want to query that data in a consistent manner immediately thereafter (with SafeMode
/// off the writes can queue up at the server and might not be immediately visible to other connections). Using
/// RequestStart you can force a query to be on the same connection as the writes, so the query won't execute
/// until the server has caught up with the writes.
/// A thread can temporarily reserve a connection from the connection pool by using RequestStart and
/// RequestDone. You are free to use any other databases as well during the request. RequestStart increments a
/// counter (for this thread) and RequestDone decrements the counter. The connection that was reserved is not
/// actually returned to the connection pool until the count reaches zero again. This means that calls to
/// RequestStart/RequestDone can be nested and the right thing will happen.
/// </remarks>
IDisposable RequestStart();

/// <summary>
/// Lets the server know that this thread is done with a series of related operations.
/// </summary>
/// <remarks>
/// Instead of calling this method it is better to put the return value of RequestStart in a using statement.
/// </remarks>
void RequestDone();

}

/// <summary>
Expand Down
47 changes: 2 additions & 45 deletions MongoRepository/Repository/MongoRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -234,51 +234,8 @@ public virtual bool Exists(Expression<Func<T, bool>> predicate)
{
return this.collection.AsQueryable<T>().Any(predicate);
}

/// <summary>
/// Lets the server know that this thread is about to begin a series of related operations that must all occur
/// on the same connection. The return value of this method implements IDisposable and can be placed in a using
/// statement (in which case RequestDone will be called automatically when leaving the using statement).
/// </summary>
/// <returns>A helper object that implements IDisposable and calls RequestDone() from the Dispose method.</returns>
/// <remarks>
/// <para>
/// Sometimes a series of operations needs to be performed on the same connection in order to guarantee correct
/// results. This is rarely the case, and most of the time there is no need to call RequestStart/RequestDone.
/// An example of when this might be necessary is when a series of Inserts are called in rapid succession with
/// SafeMode off, and you want to query that data in a consistent manner immediately thereafter (with SafeMode
/// off the writes can queue up at the server and might not be immediately visible to other connections). Using
/// RequestStart you can force a query to be on the same connection as the writes, so the query won't execute
/// until the server has caught up with the writes.
/// </para>
/// <para>
/// A thread can temporarily reserve a connection from the connection pool by using RequestStart and
/// RequestDone. You are free to use any other databases as well during the request. RequestStart increments a
/// counter (for this thread) and RequestDone decrements the counter. The connection that was reserved is not
/// actually returned to the connection pool until the count reaches zero again. This means that calls to
/// RequestStart/RequestDone can be nested and the right thing will happen.
/// </para>
/// <para>
/// Use the connectionstring to specify the readpreference; add "readPreference=X" where X is one of the following
/// values: primary, primaryPreferred, secondary, secondaryPreferred, nearest.
/// See http://docs.mongodb.org/manual/applications/replication/#read-preference
/// </para>
/// </remarks>
public virtual IDisposable RequestStart()
{
return this.collection.Database.RequestStart();
}

/// <summary>
/// Lets the server know that this thread is done with a series of related operations.
/// </summary>
/// <remarks>
/// Instead of calling this method it is better to put the return value of RequestStart in a using statement.
/// </remarks>
public virtual void RequestDone()
{
this.collection.Database.RequestDone();
}



#region IQueryable<T>
/// <summary>
Expand Down
1 change: 0 additions & 1 deletion MongoRepository/RepositoryManager/IRepositoryManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
{
using System.Collections.Generic;
using MongoDB.Driver;
using System;

/// <summary>
/// IRepositoryManager definition.
Expand Down
4 changes: 2 additions & 2 deletions MongoRepository/RepositoryManager/MongoRepositoryManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ public virtual void ReIndex()
[Obsolete("This method will be removed in the next version of the driver")]
public virtual long GetTotalDataSize()
{
return this.collection.GetTotalDataSize();
return this.collection.GetStats().DataSize;
}

/// <summary>
Expand All @@ -245,7 +245,7 @@ public virtual long GetTotalDataSize()
[Obsolete("This method will be removed in the next version of the driver")]
public virtual long GetTotalStorageSize()
{
return this.collection.GetTotalStorageSize();
return this.collection.GetStats().StorageSize;
}

/// <summary>
Expand Down
10 changes: 7 additions & 3 deletions MongoRepository/packages.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="mongocsharpdriver" version="1.11.0" targetFramework="net35" />
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="mongocsharpdriver" version="2.4.3" targetFramework="net45" />
<package id="MongoDB.Bson" version="2.4.3" targetFramework="net45" />
<package id="MongoDB.Driver" version="2.4.3" targetFramework="net45" />
<package id="MongoDB.Driver.Core" version="2.4.3" targetFramework="net45" />
<package id="System.Runtime.InteropServices.RuntimeInformation" version="4.0.0" targetFramework="net45" />
</packages>
12 changes: 6 additions & 6 deletions MongoRepositoryTests/App.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<connectionStrings>
<add name="MongoServerSettings" connectionString="mongodb://localhost/MongoRepositoryTests" />
</connectionStrings>
</configuration>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<connectionStrings>
<add name="MongoServerSettings" connectionString="mongodb://localhost/MongoRepositoryTests"/>
</connectionStrings>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2"/></startup></configuration>
4 changes: 2 additions & 2 deletions MongoRepositoryTests/Entities/Animals.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using MongoRepository;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Bson.Serialization.Attributes;
using MongoRepository;

namespace MongoRepositoryTests.Entities
{
Expand Down
2 changes: 0 additions & 2 deletions MongoRepositoryTests/Entities/CustomIDEntity.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using MongoRepository;
using System;
using MongoDB.Bson.Serialization.Attributes;

namespace MongoRepositoryTests.Entities
{
Expand Down
2 changes: 1 addition & 1 deletion MongoRepositoryTests/Entities/Customer.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
using MongoRepository;
using MongoDB.Bson.Serialization.Attributes;
using MongoRepository;

namespace MongoRepositoryTests.Entities
{
Expand Down
3 changes: 1 addition & 2 deletions MongoRepositoryTests/Entities/Product.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using MongoRepository;
using MongoRepository;

namespace MongoRepositoryTests.Entities
{
Expand Down
4 changes: 1 addition & 3 deletions MongoRepositoryTests/MongoRepositoryManagerTest.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using MongoRepository;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace MongoRepositoryTests
{
Expand Down
Loading