Exemplo n.º 1
0
 /// <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)));
 }
Exemplo n.º 2
0
 public void Save <T>(IEnumerable <T> entities) where T : IEntity
 {
     Run.Sync(() => SaveAsync(entities));
 }
Exemplo n.º 3
0
 public void Delete <T>(string ID) where T : IEntity
 {
     Run.Sync(() => DeleteAsync <T>(ID));
 }
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>
 /// 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.º 6
0
 /// <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>()));
 }
Exemplo n.º 8
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.º 9
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.º 10
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.º 11
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.º 12
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.º 13
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.º 14
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.º 15
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>
 /// <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));
 }
Exemplo n.º 16
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 void Save <T>(this T entity) where T : IEntity
 {
     Run.Sync(() => SaveAsync(entity));
 }
Exemplo n.º 17
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>
 /// <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));
 }
Exemplo n.º 18
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 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));
 }
Exemplo n.º 20
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 void DeleteAll <T>(this IEnumerable <T> entities) where T : IEntity
 {
     Run.Sync(() => DeleteAllAsync(entities));
 }
Exemplo n.º 21
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.º 22
0
 /// <summary>
 /// Run the update command in MongoDB.
 /// </summary>
 public void Execute()
 {
     Run.Sync(ExecuteAsync);
 }
Exemplo n.º 23
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.º 24
0
 /// <summary>
 /// Run the update command with pipeline stages
 /// </summary>
 public void ExecutePipeline()
 {
     Run.Sync(ExecutePipelineAsync);
 }
Exemplo n.º 25
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.º 26
0
 /// <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));
 }
Exemplo n.º 27
0
 public void SavePreserving <T>(T entity, Expression <Func <T, object> > preservation) where T : IEntity
 {
     Run.Sync(() => SavePreservingAsync(entity, preservation));
 }
Exemplo n.º 28
0
 /// <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));
 }
Exemplo n.º 29
0
 public void Delete <T>(Expression <Func <T, bool> > expression) where T : IEntity
 {
     Run.Sync(() => DeleteAsync(expression));
 }
Exemplo n.º 30
0
 /// <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)));
 }