Skip to content
This repository has been archived by the owner on Oct 5, 2023. It is now read-only.

Commit

Permalink
Initial Commit of StepByStepGuideToMongoDB Sample
Browse files Browse the repository at this point in the history
  • Loading branch information
HowardvanRooijen committed Dec 6, 2010
0 parents commit 52ced72
Show file tree
Hide file tree
Showing 35 changed files with 1,794 additions and 0 deletions.
32 changes: 32 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
obj
bin
Bin
debug
Debug
Debug_NoPostSharp
release
Release
Data
Drops
_Resharper.*
*.opensdf
*.sdf
*.xap
*.old
*.user
*.csproj.user
*.resharper.user
*.ReSharper.user
*.resharper
*.ReSharper
*.suo
*.cache
*.Cache
*~
*.swp
*.dbproj.user
*.dbproj.schemaview
*.dbmdl
*.log
*.ser
*.dbmdl
40 changes: 40 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
__ ___
/\ \ __ __ /\_ \
__ ___ \_\ \ /\_\/\_\ ___ ____ __ ___ ___ _____\//\ \ __ ____
/'__`\/' _ `\ /'_` \ \/\ \/\ \ /' _ `\ /',__\ /'__`\ /' __` __`\/\ '__`\\ \ \ /'__`\ /',__\
/\ __//\ \/\ \/\ \L\ \ \ \ \ \ \/\ \/\ \ /\__, `\\ \L\.\_/\ \/\ \/\ \ \ \L\ \\_\ \_/\ __//\__, `\
\ \____\ \_\ \_\ \___,_\_\ \ \ \_\ \_\ \_\ \/\____/ \__/.\_\ \_\ \_\ \_\ \ ,__//\____\ \____\/\____/
\/____/\/_/\/_/\/__,_ /\ \_\ \/_/\/_/\/_/ \/___/ \/__/\/_/\/_/\/_/\/_/\ \ \/ \/____/\/____/\/___/
\ \____/ \ \_\
\/___/ \/_/

endjin samples
==============

About
=====
A place for blog code samples to live.


Ingredients
===========


Install
=======


Contribute
==========


Support / Help
==============


Credits & Thanks
================


Version History
===============
24 changes: 24 additions & 0 deletions StepByStepGuideToMongoDB/ReferencedAssemblies/NOrm/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Copyright (c) 2010, Andrew T. Theken
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the <organization> nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Binary file not shown.
22 changes: 22 additions & 0 deletions StepByStepGuideToMongoDB/ReferencedAssemblies/NOrm/README.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
NoRM is a .Net library for connecting to the document-oriented database, MongoDB.
=================================================================================

*We're _incubating_, things may be broken, may not do what you think they should, or otherwise just not be what you expect. We're working as fast as we can to bring this up to a best-of-class library for interacting with MongoDB on the .Net platform. If you have ideas how we can do that, let us know - or fork them and share with us. _If any of this scares you, you should hold off until the code is a bit more mature._*

_NoRM provides:_

* Strongly-typed interaction when querying and updating collections.
* Improved interface to send common Mongo commands (creating indices, getting all the existing dbs and collections, etc.).
* Ultra-fast de/serialization of BSON to .Net CLR types and back.
* An optional fluent configuration for mapping types and properties to different names and collections in the DB.
* LINQ-to-Mongo
* NoRM will work under both Mono & .Net


If you have any questions or ideas, please use the [Google Group](http://groups.google.com/group/norm-mongodb) to convey them (Hint: this will also be a good way to be notified when we get close to a release)

It would also be useful to read what we have on the [wiki](http://wiki.github.com/atheken/NoRM/) (we know it's sparse, workin' on that, too)


* The NoRM.dll can connect to MongoDB using a trusted connection, this is the workhorse of NoRM, and all you really need to get started.
* The NoRM.Tests.dll are nunit tests for NoRM, We are much more likely to accept patches that have corresponding tests.
20 changes: 20 additions & 0 deletions StepByStepGuideToMongoDB/Solutions/StepByStepGuideToMongoDB.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StepByStepGuideToMongoDB", "StepByStepGuideToMongoDB\StepByStepGuideToMongoDB.csproj", "{C5AB7A8F-2C10-4702-BFAF-9A2FB7ABE88E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x86 = Debug|x86
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C5AB7A8F-2C10-4702-BFAF-9A2FB7ABE88E}.Debug|x86.ActiveCfg = Debug|x86
{C5AB7A8F-2C10-4702-BFAF-9A2FB7ABE88E}.Debug|x86.Build.0 = Debug|x86
{C5AB7A8F-2C10-4702-BFAF-9A2FB7ABE88E}.Release|x86.ActiveCfg = Release|x86
{C5AB7A8F-2C10-4702-BFAF-9A2FB7ABE88E}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0"?>
<configuration>
<connectionStrings>
<add name="CLub" connectionString="mongodb://127.0.0.1/ClubCollection"/>
</connectionStrings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
</configuration>
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
namespace StepByStepGuideToMongoDB.Contracts.Framework.Infrastructure.Repositories
{
#region Using Directives

using System.Linq;

using StepByStepGuideToMongoDB.Contracts.Framework.Infrastructure.Specifications;

#endregion

/// <summary>
/// Defines a LINQ implementation of the Repository Pattern that takes in a Specification to define
/// the items that should be returned.
/// </summary>
/// <typeparam name="T">
/// Type to be retrieved from readonly store
/// </typeparam>
public interface IReadOnlyLinqRepository<T>
{
/// <summary>
/// Finds an item by a specification
/// </summary>
/// <param name="specification">The specification.</param>
/// <typeparam name="T">Type of entity to find</typeparam>
/// <returns>The the matching item</returns>
T FindOne(ILinqSpecification<T> specification);

/// <summary>
/// Finds all items within the repository.
/// </summary>
/// <typeparam name="T">Type of entity to find</typeparam>
/// <returns>All items in the repository</returns>
IQueryable<T> FindAll();

/// <summary>
/// Finds all items by a specification.
/// </summary>
/// <param name="specification">The specification.</param>
/// <typeparam name="T">Type of entity to find</typeparam>
/// <returns>All matching items</returns>
IQueryable<T> FindAll(ILinqSpecification<T> specification);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace StepByStepGuideToMongoDB.Contracts.Framework.Infrastructure.Repositories
{
public interface IUniqueIdentifier
{
string Id { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace StepByStepGuideToMongoDB.Contracts.Framework.Infrastructure.Repositories
{
public interface IWritableLinqRepository<T> : IReadOnlyLinqRepository<T>
{
void Delete(T item);

void Save(T item);

void Update(T item);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
namespace StepByStepGuideToMongoDB.Contracts.Framework.Infrastructure.Specifications
{
#region Using Directives

using System.Linq;

#endregion

/// <summary>
/// Defines a contract for the behaviour of a LINQ Specification design pattern.
/// </summary>
/// <typeparam name="T">
/// Type to be used for Input / Output
/// </typeparam>
public interface ILinqSpecification<T> : ILinqSpecification<T, T>
{
}

/// <summary>
/// Defines a contract for the behaviour of a LINQ Specification design pattern.
/// </summary>
/// <typeparam name="T">
/// The input type.
/// </typeparam>
/// <typeparam name="TResult">
/// The output type.
/// </typeparam>
public interface ILinqSpecification<T, TResult>
{
/// <summary>
/// satisfying elements from.
/// </summary>
/// <param name="candidates">
/// The candidates.
/// </param>
/// <returns>
/// A list of satisfying elements.
/// </returns>
IQueryable<TResult> SatisfyingElementsFrom(IQueryable<T> candidates);
}
}

// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ILinqSpecification.cs" company="Endjin Ltd">
// Copyright © 2010 Endjin Ltd
// </copyright>
// --------------------------------------------------------------------------------------------------------------------
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace StepByStepGuideToMongoDB.Contracts.Infrastructure.Repositories
{
#region Using Directives

using System.Collections.Generic;

using StepByStepGuideToMongoDB.Domain;

#endregion

public interface IRemoteClubDataSource
{
IEnumerable<Club> GetAllClubs();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
namespace StepByStepGuideToMongoDB.Contracts.Tasks
{
#region Using Directives

using System.Collections.Generic;

using StepByStepGuideToMongoDB.Domain;

#endregion

public interface IClubTasks
{
IEnumerable<Club> RetrieveClubsFromRemoteDataSource();

void AddToLocalRepository(IEnumerable<Club> clubs);

Club GetByContactName(string contactName);

void Update(Club club);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
namespace StepByStepGuideToMongoDB.Domain
{
#region Using Directives

using System;
using System.Text;

using StepByStepGuideToMongoDB.Contracts.Framework.Infrastructure.Repositories;
using StepByStepGuideToMongoDB.Framework.Extensions;

#endregion

public class Club : IUniqueIdentifier
{
public Club()
{
this.Id = Guid.NewGuid().ToString();
}

public string Ages { get; set; }

public Contact Contact { get; set; }

public string Facility { get; set; }

public string Id { get; set; }

public string Info { get; set; }

public string Leagues { get; set; }

public string Name { get; set; }

public string Sport { get; set; }

public string Training { get; set; }

public override string ToString()
{
var sb = new StringBuilder();

sb.AppendIfValueNotEmpty("Name: ", this.Name);
sb.AppendIfValueNotEmpty("Facility: ", this.Facility);
sb.AppendIfValueNotEmpty("Info: ", this.Info);
sb.AppendIfValueNotEmpty("Leagues: ", this.Leagues);
sb.AppendIfValueNotEmpty("Sport: ", this.Sport);
sb.AppendIfValueNotEmpty("Training: ", this.Training);
sb.AppendLine("Contact: ");
sb.AppendLine(this.Contact.ToString());

return sb.ToString();
}
}
}
Loading

0 comments on commit 52ced72

Please sign in to comment.