Esempio 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)));
 }
Esempio 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)));
 }
Esempio 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)));
 }
Esempio 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)));
 }
Esempio n. 5
0
 /// <summary>
 /// Run the update command in MongoDB.
 /// </summary>
 public void Execute()
 {
     Run.Sync(ExecuteAsync);
 }
Esempio n. 6
0
 /// <summary>
 /// Run the update command with pipeline stages
 /// </summary>
 public void ExecutePipeline()
 {
     Run.Sync(ExecutePipelineAsync);
 }
Esempio 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));
 }
Esempio n. 8
0
 /// <summary>
 /// Run the update command in MongoDB.
 /// </summary>
 public UpdateResult Execute()
 {
     return(Run.Sync(() => ExecuteAsync()));
 }
Esempio 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));
 }
Esempio 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));
 }
Esempio 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));
 }
Esempio 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));
 }
Esempio 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)));
 }
Esempio 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)));
 }
Esempio 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));
 }
Esempio 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())));
 }
 /// <summary>
 /// Call this method to finalize defining the index after setting the index keys and options.
 /// </summary>
 public void Create()
 {
     Run.Sync(() => CreateAsync());
 }