Exemplo n.º 1
0
 /// <summary>
 /// Save this entity while preserving some property values in the database.
 /// The properties to be preserved can be specified with a 'New' expression.
 /// <para>TIP: The 'New' expression should specify only root level properties.</para>
 /// </summary>
 /// <typeparam name="T">Any class that implements IEntity</typeparam>
 /// <param name="entity">The entity to save</param>
 /// <param name="preservation">x => new { x.PropOne, x.PropTwo }</param>
 public static ReplaceOneResult SavePreserving <T>(this T entity, Expression <Func <T, object> > preservation) where T : IEntity
 {
     return(Run.Sync(() => SavePreservingAsync(entity, preservation)));
 }
Exemplo n.º 2
0
 /// <summary>
 /// Deletes a single entity from MongoDB.
 /// <para>HINT: If this entity is referenced by one-to-many/many-to-many relationships, those references are also deleted.</para>
 /// </summary>
 public static DeleteResult Delete <T>(this T entity) where T : IEntity
 {
     return(Run.Sync(() => DeleteAsync(entity)));
 }
Exemplo n.º 3
0
 /// <summary>
 /// Replaces an IEntity in the databse if a matching item is found (by ID) or creates a new one if not found.
 /// <para>WARNING: The shape of the IEntity in the database is always owerwritten with the current shape of the IEntity. So be mindful of data loss due to schema changes.</para>
 /// </summary>
 public static ReplaceOneResult Save <T>(this T entity) where T : IEntity
 {
     return(Run.Sync(() => SaveAsync(entity)));
 }
Exemplo n.º 4
0
 /// <summary>
 /// Replaces Entities in the databse if matching items are found (by ID) or creates new ones if not found.
 /// <para>WARNING: The shape of the IEntity in the database is always owerwritten with the current shape of the IEntity. So be mindful of data loss due to schema changes.</para>
 /// </summary>
 public static BulkWriteResult <T> Save <T>(this IEnumerable <T> entities) where T : IEntity
 {
     return(Run.Sync(() => SaveAsync(entities)));
 }
Exemplo n.º 5
0
 /// <summary>
 /// Run the update command in MongoDB.
 /// </summary>
 public void Execute()
 {
     Run.Sync(ExecuteAsync);
 }
Exemplo n.º 6
0
 /// <summary>
 /// Run the update command with pipeline stages
 /// </summary>
 public void ExecutePipeline()
 {
     Run.Sync(ExecutePipelineAsync);
 }
Exemplo n.º 7
0
 /// <summary>
 /// Removes child references.
 /// </summary>
 /// <param name="children">The child Entities to remove the references of.</param>
 /// <param name="session">An optional session if using within a transaction</param>
 public void Remove(IEnumerable <TChild> children, IClientSessionHandle session = null)
 {
     Run.Sync(() => RemoveAsync(children, session));
 }
Exemplo n.º 8
0
 /// <summary>
 /// Run the update command in MongoDB.
 /// </summary>
 public UpdateResult Execute()
 {
     return(Run.Sync(() => ExecuteAsync()));
 }
Exemplo n.º 9
0
 /// <summary>
 /// Removes a child reference.
 /// </summary>
 /// <param name="child">The child IEntity to remove the reference of.</param>
 /// <param name="session">An optional session if using within a transaction</param>
 public void Remove(TChild child, IClientSessionHandle session = null)
 {
     Run.Sync(() => RemoveAsync(child, session));
 }
Exemplo n.º 10
0
 /// <summary>
 /// Removes a child reference by ID.
 /// </summary>
 /// <param name="childID">The ID of the child entity to remove the reference of.</param>
 /// <param name="session">An optional session if using within a transaction</param>
 public void Remove(string childID, IClientSessionHandle session = null)
 {
     Run.Sync(() => RemoveAsync(childID, session));
 }
Exemplo n.º 11
0
 /// <summary>
 /// Adds a new child reference by ID.
 /// </summary>
 /// <param name="childID">The ID of the child entity to add.</param>
 /// <param name="session">An optional session if using within a transaction</param>
 public void Add(string childID, IClientSessionHandle session = null)
 {
     Run.Sync(() => AddAsync(childID, session));
 }
Exemplo n.º 12
0
 /// <summary>
 /// Adds a new child reference.
 /// <para>WARNING: Make sure to save the parent and child Entities before calling this method.</para>
 /// </summary>
 /// <param name="child">The child Entity to add.</param>
 /// <param name="session">An optional session if using within a transaction</param>
 public void Add(TChild child, IClientSessionHandle session = null)
 {
     Run.Sync(() => AddAsync(child, session));
 }
Exemplo n.º 13
0
 /// <summary>
 /// Get the number of children for a relationship
 /// </summary>
 /// <param name="session">An optional session if using within a transaction</param>
 /// <param name="options">An optional AggregateOptions object</param>
 public long ChildrenCount(IClientSessionHandle session = null, CountOptions options = null)
 {
     return(Run.Sync(() => ChildrenCountAsync(session, options)));
 }
Exemplo n.º 14
0
 /// <summary>
 /// Deletes multiple entities from the database
 /// <para>HINT: If these entities are referenced by one-to-many/many-to-many relationships, those references are also deleted.</para>
 /// </summary>
 public static DeleteResult DeleteAll <T>(this IEnumerable <T> entities) where T : IEntity
 {
     return(Run.Sync(() => DeleteAllAsync(entities)));
 }
Exemplo n.º 15
0
 /// <summary>
 /// Removes child references.
 /// </summary>
 /// <param name="childIDs">The IDs of the child Entities to remove the references of</param>
 /// <param name="session">An optional session if using within a transaction</param>
 public void Remove(IEnumerable <string> childIDs, IClientSessionHandle session = null)
 {
     Run.Sync(() => RemoveAsync(childIDs, session));
 }
Exemplo n.º 16
0
 /// <summary>
 /// Returns an atomically generated sequential number for the given Entity type everytime the method is called
 /// </summary>
 /// <typeparam name="T">The type of entity to get the next sequential number for</typeparam>
 public static ulong NextSequentialNumber <T>(this T entity) where T : IEntity
 {
     return(Run.Sync(() => DB.NextSequentialNumberAsync <T>(entity.Database())));
 }
Exemplo n.º 17
0
 /// <summary>
 /// Call this method to finalize defining the index after setting the index keys and options.
 /// </summary>
 public void Create()
 {
     Run.Sync(() => CreateAsync());
 }