Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #58 from TurnerSoftware/mapping-overhaul
Mapping Overhaul
- Loading branch information
Showing
119 changed files
with
1,508 additions
and
1,558 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
using System; | ||
using System.Reflection; | ||
using MongoFramework.Infrastructure.Mapping; | ||
|
||
namespace MongoFramework.Attributes | ||
{ | ||
public abstract class MutatePropertyAttribute : Attribute | ||
{ | ||
public virtual void OnInsert(object target, PropertyInfo property) { } | ||
public virtual void OnUpdate(object target, PropertyInfo property) { } | ||
public virtual void OnSelect(object target, PropertyInfo property) { } | ||
public virtual void OnInsert(object target, IEntityProperty property) { } | ||
public virtual void OnUpdate(object target, IEntityProperty property) { } | ||
public virtual void OnSelect(object target, IEntityProperty property) { } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,13 @@ | ||
using System; | ||
using MongoDB.Driver; | ||
using MongoFramework.Infrastructure; | ||
using MongoFramework.Infrastructure.Indexing; | ||
using MongoFramework.Infrastructure.Mapping; | ||
|
||
namespace MongoFramework | ||
{ | ||
public interface IMongoDbConnection : IEntityMapperFactory, IEntityIndexMapperFactory, IDisposable | ||
public interface IMongoDbConnection : IDisposable | ||
{ | ||
IMongoClient Client { get; } | ||
IMongoDatabase GetDatabase(); | ||
IDiagnosticListener DiagnosticListener { get; } | ||
IDiagnosticListener DiagnosticListener { set; get; } | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/MongoFramework/Infrastructure/Commands/AddEntityCommand.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using MongoDB.Driver; | ||
|
||
namespace MongoFramework.Infrastructure.Commands | ||
{ | ||
public class AddEntityCommand<TEntity> : IWriteCommand<TEntity> where TEntity : class | ||
{ | ||
private EntityEntry<TEntity> EntityEntry { get; } | ||
|
||
public AddEntityCommand(EntityEntry<TEntity> entityEntry) | ||
{ | ||
EntityEntry = entityEntry; | ||
} | ||
|
||
public IEnumerable<WriteModel<TEntity>> GetModel() | ||
{ | ||
yield return new InsertOneModel<TEntity>(EntityEntry.Entity); | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/MongoFramework/Infrastructure/Commands/IWriteCommand.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using MongoDB.Driver; | ||
|
||
namespace MongoFramework.Infrastructure.Commands | ||
{ | ||
public interface IWriteCommand<TEntity> where TEntity : class | ||
{ | ||
IEnumerable<WriteModel<TEntity>> GetModel(); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/MongoFramework/Infrastructure/Commands/UpdateEntityCommand.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using MongoDB.Driver; | ||
|
||
namespace MongoFramework.Infrastructure.Commands | ||
{ | ||
public class UpdateEntityCommand<TEntity> : IWriteCommand<TEntity> where TEntity : class | ||
{ | ||
private EntityEntry<TEntity> EntityEntry { get; } | ||
|
||
public UpdateEntityCommand(EntityEntry<TEntity> entityEntry) | ||
{ | ||
EntityEntry = entityEntry; | ||
} | ||
|
||
public IEnumerable<WriteModel<TEntity>> GetModel() | ||
{ | ||
//var idFieldValue = EntityMapper.GetIdValue(entry.Entity); | ||
//var filter = Builders<TEntity>.Filter.Eq(idFieldName, idFieldValue); | ||
//var updateDefintion = UpdateDefinitionHelper.CreateFromDiff<TEntity>(EntityEntry.OriginalValues, EntityEntry.CurrentValues); | ||
|
||
////MongoDB doesn't like it if an UpdateDefinition is empty. | ||
////This is primarily to work around a mutation that may set an entity to its default state. | ||
//if (updateDefintion.HasChanges()) | ||
//{ | ||
// writeModel.Add(new UpdateOneModel<TEntity>(filter, updateDefintion)); | ||
//} | ||
//yield return new InsertOneModel<TEntity>(EntityEntry.Entity); | ||
yield break; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../Infrastructure/NoOpDiagnosticListener.cs → ...ure/Diagnostics/NoOpDiagnosticListener.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.