/// <summary> /// Persists multiple entities to MongoDB in a single bulk operation /// </summary> /// <typeparam name="T">Any class that implements IEntity</typeparam> /// <param name="entities">The entities to persist</param> /// <param name="session">An optional session if using within a transaction</param> public BulkWriteResult <T> Save <T>(IEnumerable <T> entities, IClientSessionHandle session = null) where T : IEntity { return(Run.Sync(() => SaveAsync(entities, session, DbName))); }
public void Save <T>(IEnumerable <T> entities) where T : IEntity { Run.Sync(() => SaveAsync(entities)); }
public void Delete <T>(string ID) where T : IEntity { Run.Sync(() => DeleteAsync <T>(ID)); }
/// <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))); }
/// <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))); }
/// <summary> /// Deletes matching entities from MongoDB /// <para>HINT: If these entities are referenced by one-to-many/many-to-many relationships, those references are also deleted.</para> /// <para>TIP: Try to keep the number of entities to delete under 100 in a batch</para> /// </summary> /// <typeparam name="T">Any class that implements IEntity</typeparam> /// <param name="expression">A lambda expression for matching entities to delete.</param> /// <param name = "session" > An optional session if using within a transaction</param> public static void Delete <T>(Expression <Func <T, bool> > expression, IClientSessionHandle session = null, string db = null) where T : IEntity { Run.Sync(() => DeleteAsync(expression, session, db)); }
/// <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 _) where T : IEntity { return(Run.Sync(() => DB.NextSequentialNumberAsync <T>())); }
/// <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)); }
/// <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)); }
/// <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)); }
/// <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)); }
/// <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)); }
/// <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)); }
/// <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))); }
/// <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> /// <typeparam name="T">Any class that implements IEntity</typeparam> /// <param name="ID">The Id of the entity to delete</param> /// <param name = "session" > An optional session if using within a transaction</param> public static void Delete <T>(string ID, IClientSessionHandle session = null, string db = null) where T : IEntity { Run.Sync(() => DeleteAsync <T>(ID, session, db)); }
/// <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 void Save <T>(this T entity) where T : IEntity { Run.Sync(() => SaveAsync(entity)); }
/// <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> /// <typeparam name="T">Any class that implements IEntity</typeparam> /// <param name="ID">The Id of the entity to delete</param> /// <param name = "session" > An optional session if using within a transaction</param> public void Delete <T>(string ID, IClientSessionHandle session = null) where T : IEntity { Run.Sync(() => DeleteAsync <T>(ID, session, DbName)); }
/// <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 void Delete <T>(this T entity) where T : IEntity { Run.Sync(() => DeleteAsync(entity)); }
/// <summary> /// Deletes the collection of a given entity type as well as the join collections for that entity. /// <para>TIP: When deleting a collection, all relationships associated with that entity type is also deleted.</para> /// </summary> /// <typeparam name="T">The entity type to drop the collection of</typeparam> /// <param name="session">An optional session if using within a transaction</param> public void DropCollection <T>(IClientSessionHandle session = null, bool _ = false) where T : IEntity { Run.Sync(() => DropCollectionAsync <T>(session)); }
/// <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 void DeleteAll <T>(this IEnumerable <T> entities) where T : IEntity { Run.Sync(() => DeleteAllAsync(entities)); }
/// <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))); }
/// <summary> /// Run the update command in MongoDB. /// </summary> public void Execute() { Run.Sync(ExecuteAsync); }
/// <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))); }
/// <summary> /// Run the update command with pipeline stages /// </summary> public void ExecutePipeline() { Run.Sync(ExecutePipelineAsync); }
/// <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))); }
/// <summary> /// Deletes matching entities from MongoDB /// <para>HINT: If these entities are referenced by one-to-many/many-to-many relationships, those references are also deleted.</para> /// <para>TIP: Try to keep the number of entities to delete under 100 in a batch</para> /// </summary> /// <typeparam name="T">Any class that implements IEntity</typeparam> /// <param name="expression">A lambda expression for matching entities to delete.</param> /// <param name = "session" > An optional session if using within a transaction</param> public void Delete <T>(Expression <Func <T, bool> > expression, IClientSessionHandle session = null) where T : IEntity { Run.Sync(() => DeleteAsync(expression, session, DbName)); }
public void SavePreserving <T>(T entity, Expression <Func <T, object> > preservation) where T : IEntity { Run.Sync(() => SavePreservingAsync(entity, preservation)); }
/// <summary> /// Deletes matching entities from MongoDB /// <para>HINT: If these entities are referenced by one-to-many/many-to-many relationships, those references are also deleted.</para> /// <para>TIP: Try to keep the number of entities to delete under 100 in a batch</para> /// </summary> /// <typeparam name="T">Any class that implements IEntity</typeparam> /// <param name="IDs">An IEnumerable of entity IDs</param> /// <param name = "session" > An optional session if using within a transaction</param> public void Delete <T>(IEnumerable <string> IDs, IClientSessionHandle session = null) where T : IEntity { Run.Sync(() => DeleteAsync <T>(IDs, session, DbName)); }
public void Delete <T>(Expression <Func <T, bool> > expression) where T : IEntity { Run.Sync(() => DeleteAsync(expression)); }
/// <summary> /// Persists an entity to MongoDB /// </summary> /// <typeparam name="T">Any class that implements IEntity</typeparam> /// <param name="entity">The instance to persist</param> /// <param name="session">An optional session if using within a transaction</param> public ReplaceOneResult Save <T>(T entity, IClientSessionHandle session = null) where T : IEntity { return(Run.Sync(() => SaveAsync(entity, session, DbName))); }