This repository was archived by the owner on Feb 22, 2020. It is now read-only.
File tree Expand file tree Collapse file tree
MongoRepository/dev/MongoRepository/Repository Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -81,10 +81,7 @@ public MongoRepository(MongoUrl url, string collectionName)
8181 /// <value>The Mongo collection (to perform advanced operations).</value>
8282 public MongoCollection < T > Collection
8383 {
84- get
85- {
86- return this . collection ;
87- }
84+ get { return this . collection ; }
8885 }
8986
9087 /// <summary>
@@ -96,12 +93,22 @@ public virtual T GetById(TKey id)
9693 {
9794 if ( typeof ( T ) . IsSubclassOf ( typeof ( Entity ) ) )
9895 {
99- return this . collection . FindOneByIdAs < T > ( new ObjectId ( id as string ) ) ;
96+ return this . GetById ( new ObjectId ( id as string ) ) ;
10097 }
10198
10299 return this . collection . FindOneByIdAs < T > ( BsonValue . Create ( id ) ) ;
103100 }
104101
102+ /// <summary>
103+ /// Returns the T by its given id.
104+ /// </summary>
105+ /// <param name="id">The Id of the entity to retrieve.</param>
106+ /// <returns>The Entity T.</returns>
107+ public virtual T GetById ( ObjectId id )
108+ {
109+ return this . collection . FindOneByIdAs < T > ( id ) ;
110+ }
111+
105112 /// <summary>
106113 /// Adds the new entity in the repository.
107114 /// </summary>
You can’t perform that action at this time.
0 commit comments