Skip to content

Commit

Permalink
Dev -> Trunk
Browse files Browse the repository at this point in the history
  • Loading branch information
RobThree committed May 20, 2014
1 parent 9957d66 commit 3051a77
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 28 deletions.
2 changes: 1 addition & 1 deletion MongoRepository/trunk/Help/MongoRepository.shfbproj
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<SccProvider>SAK</SccProvider>
<SccAuxPath>SAK</SccAuxPath>
<SccLocalPath>SAK</SccLocalPath>
<HelpFileVersion>1.6.4.0</HelpFileVersion>
<HelpFileVersion>1.6.5.0</HelpFileVersion>
<BuildAssemblerVerbosity>OnlyWarningsAndErrors</BuildAssemblerVerbosity>
<HelpFileFormat>HtmlHelp1, Website</HelpFileFormat>
<IndentHtml>False</IndentHtml>
Expand Down
7 changes: 4 additions & 3 deletions MongoRepository/trunk/MongoRepository.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
<package xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<metadata xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<id>MongoRepository</id>
<version>1.6.4</version>
<title>MongoRepository</title>
<version>1.6.5</version>
<authors>tgeek, RobIII</authors>
<owners>tgeek</owners>
<licenseUrl>http://mongorepository.codeplex.com/license</licenseUrl>
Expand All @@ -12,14 +13,14 @@
<tags>mongo mongodb repository</tags>
<iconUrl>http://download-codeplex.sec.s-msft.com/Download?ProjectName=mongorepository&amp;DownloadId=334950&amp;Build=19692</iconUrl>
<releaseNotes>
Updated to MongoCSharp driver 1.9.0.200
Updated to MongoCSharp driver 1.9.1.221, added GetById(ObjectId) overload, added CollectionName property (convenience property)
</releaseNotes>
<summary>
Provides a repository pattern on top of 10gen's MongoDB C# driver.
</summary>
<language>en-US</language>
<dependencies>
<dependency id="mongocsharpdriver" version="[1.9.0]" />
<dependency id="mongocsharpdriver" version="[1.9.1]" />
</dependencies>
</metadata>
<files>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@
<DocumentationFile>bin\Release\MongoRepository.Net35.xml</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="MongoDB.Bson, Version=1.9.0.200, Culture=neutral, PublicKeyToken=f686731cfb9cc103, processorArchitecture=MSIL">
<Reference Include="MongoDB.Bson, Version=1.9.1.221, Culture=neutral, PublicKeyToken=f686731cfb9cc103, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\mongocsharpdriver.1.9.0\lib\net35\MongoDB.Bson.dll</HintPath>
<HintPath>..\packages\mongocsharpdriver.1.9.1\lib\net35\MongoDB.Bson.dll</HintPath>
</Reference>
<Reference Include="MongoDB.Driver, Version=1.9.0.200, Culture=neutral, PublicKeyToken=f686731cfb9cc103, processorArchitecture=MSIL">
<Reference Include="MongoDB.Driver, Version=1.9.1.221, Culture=neutral, PublicKeyToken=f686731cfb9cc103, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\mongocsharpdriver.1.9.0\lib\net35\MongoDB.Driver.dll</HintPath>
<HintPath>..\packages\mongocsharpdriver.1.9.1\lib\net35\MongoDB.Driver.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@
<DocumentationFile>bin\Release\MongoRepository.Net40.xml</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="MongoDB.Bson, Version=1.9.0.200, Culture=neutral, PublicKeyToken=f686731cfb9cc103, processorArchitecture=MSIL">
<Reference Include="MongoDB.Bson, Version=1.9.1.221, Culture=neutral, PublicKeyToken=f686731cfb9cc103, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\mongocsharpdriver.1.9.0\lib\net35\MongoDB.Bson.dll</HintPath>
<HintPath>..\packages\mongocsharpdriver.1.9.1\lib\net35\MongoDB.Bson.dll</HintPath>
</Reference>
<Reference Include="MongoDB.Driver, Version=1.9.0.200, Culture=neutral, PublicKeyToken=f686731cfb9cc103, processorArchitecture=MSIL">
<Reference Include="MongoDB.Driver, Version=1.9.1.221, Culture=neutral, PublicKeyToken=f686731cfb9cc103, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\mongocsharpdriver.1.9.0\lib\net35\MongoDB.Driver.dll</HintPath>
<HintPath>..\packages\mongocsharpdriver.1.9.1\lib\net35\MongoDB.Driver.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@
<DocumentationFile>bin\Release\MongoRepository.Net45.xml</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="MongoDB.Bson, Version=1.9.0.200, Culture=neutral, PublicKeyToken=f686731cfb9cc103, processorArchitecture=MSIL">
<Reference Include="MongoDB.Bson, Version=1.9.1.221, Culture=neutral, PublicKeyToken=f686731cfb9cc103, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\mongocsharpdriver.1.9.0\lib\net35\MongoDB.Bson.dll</HintPath>
<HintPath>..\packages\mongocsharpdriver.1.9.1\lib\net35\MongoDB.Bson.dll</HintPath>
</Reference>
<Reference Include="MongoDB.Driver, Version=1.9.0.200, Culture=neutral, PublicKeyToken=f686731cfb9cc103, processorArchitecture=MSIL">
<Reference Include="MongoDB.Driver, Version=1.9.1.221, Culture=neutral, PublicKeyToken=f686731cfb9cc103, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\mongocsharpdriver.1.9.0\lib\net35\MongoDB.Driver.dll</HintPath>
<HintPath>..\packages\mongocsharpdriver.1.9.1\lib\net35\MongoDB.Driver.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,12 @@ public MongoRepository(MongoUrl url, string collectionName)
/// <value>The Mongo collection (to perform advanced operations).</value>
public MongoCollection<T> Collection
{
get
{
return this.collection;
}
get { return this.collection; }
}

public string CollectionName
{
get { return this.collection.Name; }
}

/// <summary>
Expand All @@ -96,12 +98,22 @@ public virtual T GetById(TKey id)
{
if (typeof(T).IsSubclassOf(typeof(Entity)))
{
return this.collection.FindOneByIdAs<T>(new ObjectId(id as string));
return this.GetById(new ObjectId(id as string));
}

return this.collection.FindOneByIdAs<T>(BsonValue.Create(id));
}

/// <summary>
/// Returns the T by its given id.
/// </summary>
/// <param name="id">The Id of the entity to retrieve.</param>
/// <returns>The Entity T.</returns>
public virtual T GetById(ObjectId id)
{
return this.collection.FindOneByIdAs<T>(id);
}

/// <summary>
/// Adds the new entity in the repository.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion MongoRepository/trunk/MongoRepository/packages.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="mongocsharpdriver" version="1.9.0" targetFramework="net45" />
<package id="mongocsharpdriver" version="1.9.1" targetFramework="net35" />
</packages>
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@
<ItemGroup>
<Reference Include="Microsoft.CSharp" />
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
<Reference Include="MongoDB.Bson, Version=1.9.0.200, Culture=neutral, PublicKeyToken=f686731cfb9cc103, processorArchitecture=MSIL">
<Reference Include="MongoDB.Bson, Version=1.9.1.221, Culture=neutral, PublicKeyToken=f686731cfb9cc103, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\mongocsharpdriver.1.9.0\lib\net35\MongoDB.Bson.dll</HintPath>
<HintPath>..\packages\mongocsharpdriver.1.9.1\lib\net35\MongoDB.Bson.dll</HintPath>
</Reference>
<Reference Include="MongoDB.Driver, Version=1.9.0.200, Culture=neutral, PublicKeyToken=f686731cfb9cc103, processorArchitecture=MSIL">
<Reference Include="MongoDB.Driver, Version=1.9.1.221, Culture=neutral, PublicKeyToken=f686731cfb9cc103, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\mongocsharpdriver.1.9.0\lib\net35\MongoDB.Driver.dll</HintPath>
<HintPath>..\packages\mongocsharpdriver.1.9.1\lib\net35\MongoDB.Driver.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
Expand Down
10 changes: 9 additions & 1 deletion MongoRepository/trunk/MongoRepositoryTests/RepoTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ public void CollectionNamesTest()
Assert.IsTrue(am.Exists);
Assert.IsInstanceOfType(a.GetById(va.Id), typeof(Dog));
Assert.AreEqual(am.Name, "AnimalsTest");
Assert.AreEqual(a.CollectionName, "AnimalsTest");

var cl = new MongoRepository<CatLike>();
var clm = new MongoRepositoryManager<CatLike>();
Expand All @@ -216,6 +217,7 @@ public void CollectionNamesTest()
Assert.IsTrue(clm.Exists);
Assert.IsInstanceOfType(cl.GetById(vcl.Id), typeof(Lion));
Assert.AreEqual(clm.Name, "Catlikes");
Assert.AreEqual(cl.CollectionName, "Catlikes");

var b = new MongoRepository<Bird>();
var bm = new MongoRepositoryManager<Bird>();
Expand All @@ -225,6 +227,7 @@ public void CollectionNamesTest()
Assert.IsTrue(bm.Exists);
Assert.IsInstanceOfType(b.GetById(vb.Id), typeof(Bird));
Assert.AreEqual(bm.Name, "Birds");
Assert.AreEqual(b.CollectionName, "Birds");

var l = new MongoRepository<Lion>();
var lm = new MongoRepositoryManager<Lion>();
Expand All @@ -234,6 +237,7 @@ public void CollectionNamesTest()
Assert.IsTrue(lm.Exists);
Assert.IsInstanceOfType(l.GetById(vl.Id), typeof(Lion));
Assert.AreEqual(lm.Name, "Catlikes");
Assert.AreEqual(l.CollectionName, "Catlikes");

var d = new MongoRepository<Dog>();
var dm = new MongoRepositoryManager<Dog>();
Expand All @@ -243,6 +247,7 @@ public void CollectionNamesTest()
Assert.IsTrue(dm.Exists);
Assert.IsInstanceOfType(d.GetById(vd.Id), typeof(Dog));
Assert.AreEqual(dm.Name, "AnimalsTest");
Assert.AreEqual(d.CollectionName, "AnimalsTest");

var m = new MongoRepository<Bird>();
var mm = new MongoRepositoryManager<Bird>();
Expand All @@ -252,6 +257,7 @@ public void CollectionNamesTest()
Assert.IsTrue(mm.Exists);
Assert.IsInstanceOfType(m.GetById(vm.Id), typeof(Macaw));
Assert.AreEqual(mm.Name, "Birds");
Assert.AreEqual(m.CollectionName, "Birds");

var w = new MongoRepository<Whale>();
var wm = new MongoRepositoryManager<Whale>();
Expand All @@ -261,7 +267,7 @@ public void CollectionNamesTest()
Assert.IsTrue(wm.Exists);
Assert.IsInstanceOfType(w.GetById(vw.Id), typeof(Whale));
Assert.AreEqual(wm.Name, "Whale");

Assert.AreEqual(w.CollectionName, "Whale");
}

[TestMethod]
Expand All @@ -287,6 +293,7 @@ public void CustomIDTest()

Assert.IsTrue(ym.Exists);
Assert.AreEqual(ym.Name, "MyTestCollection");
Assert.AreEqual(y.CollectionName, "MyTestCollection");
Assert.IsInstanceOfType(y.GetById("xyz"), typeof(CustomIDEntityCustomCollection));

y.Delete("xyz");
Expand Down Expand Up @@ -314,6 +321,7 @@ public void OverrideCollectionName()
_customerRepo.Add(new Customer() { FirstName = "Test" });
Assert.IsTrue(_customerRepo.Single().FirstName.Equals("Test"));
Assert.AreEqual("TestCustomers123", _customerRepo.Collection.Name);
Assert.AreEqual("TestCustomers123", ((MongoRepository<Customer>)_customerRepo).CollectionName);

IRepositoryManager<Customer> _curstomerRepoManager = new MongoRepositoryManager<Customer>("mongodb://localhost/MongoRepositoryTests", "TestCustomers123");
Assert.AreEqual("TestCustomers123", _curstomerRepoManager.Name);
Expand Down
2 changes: 1 addition & 1 deletion MongoRepository/trunk/MongoRepositoryTests/packages.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="mongocsharpdriver" version="1.9.0" targetFramework="net40" />
<package id="mongocsharpdriver" version="1.9.1" targetFramework="net40" />
</packages>

0 comments on commit 3051a77

Please sign in to comment.