OrderRepository

Namespace: Babel.Data Assembly: Babel.Data.dll

An order repository.

public class OrderRepository : GenericRepository<Order>, IOrderRepository, IGenericRepository<Order>

Inheritance

objectGenericRepository<Order>OrderRepository

Implements

IOrderRepository, IGenericRepository<Order>

Inherited Members

GenericRepository<Order>.Get(Expression<Func<Order, bool>>, Func<IQueryable<Order>, IOrderedQueryable<Order>>, string, string, int?, int?), GenericRepository<Order>.GetAsync(Expression<Func<Order, bool>>, Func<IQueryable<Order>, IOrderedQueryable<Order>>, string, string, int?, int?, CancellationToken), GenericRepository<Order>.QueryAsync(string, string, string, string, int?, int?, CancellationToken), GenericRepository<Order>.GetById(params object[]), GenericRepository<Order>.GetByIdAsync(params object[]), GenericRepository<Order>.GetByIdAsync(object[], CancellationToken), GenericRepository<Order>.CountAsync(Expression<Func<Order, bool>>, CancellationToken), GenericRepository<Order>.CountAsync(string, CancellationToken), GenericRepository<Order>.Insert(Order), GenericRepository<Order>.InsertAsync(Order, CancellationToken), GenericRepository<Order>.Update(Order), GenericRepository<Order>.Delete(params object[]), GenericRepository<Order>.Delete(Order), GenericRepository<Order>.Save(), GenericRepository<Order>.SaveAsync(CancellationToken), GenericRepository<Order>.DbSet, GenericRepository<Order>.Context, object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

Constructors

OrderRepository(BabelDbContext)

Initializes a new instance of the OrderRepository class.

public OrderRepository(BabelDbContext context)

Parameters

NameDescription

The database context.

Methods

Delete(IEnumerable<int>)

Deletes a list of order with the given primary key values. Begins tracking the given entities in the Detached state such that they will be deleted in the database when SaveChanges() is called.

public void Delete(IEnumerable<int> orderIds)

Parameters

NameDescription

orderIds IEnumerable<int>

The order primary key ids to delete.

DeleteResourceAsync(int, IEnumerable<int>)

Asynchronously deletes the resources for a given order. Begins tracking the given entities in the Detached state such that they will be deleted in the database when SaveChanges() is called.

public Task DeleteResourceAsync(int orderId, IEnumerable<int> resourcesIds)

Parameters

NameDescription

orderId int

The order primary key.

resourcesIds IEnumerable<int>

List of resources primary keys.

Returns

NameDescription

A task that represents the asynchronous delete operation.

GetByIdAsync(params object[])

Asynchronously gets an entity with the given primary key values. If an entity with the given primary key values exists in the context, then it is returned immediately without making a request to the store. Otherwise, a request is made to the store for an entity with the given primary key values and this entity, if found, is attached to the context and returned. If no entity is found in the context or the store, then null is returned.

public override Task<Order> GetByIdAsync(params object[] ids)

Parameters

NameDescription

ids object[]

The values of the primary key for the entity to be found.

Returns

NameDescription

A task that represents the asynchronous get operation. The task result contains the entity found, or null.

GetResourcesAsync(int)

Asynchronously gets a list of resources for the given order.

public Task<List<Resource>> GetResourcesAsync(int orderId)

Parameters

NameDescription

orderId int

The order primary key.

Returns

NameDescription

An asynchronous result that yields the order resources.

InsertAsync(Order, CancellationToken)

Asynchronously inserts the given entity in the repository. Begins tracking the given entity, and any other reachable entities that are not already being tracked, in the Added state such that they will be inserted into the database when SaveChanges() is called.

public override Task<EntityEntry<Order>> InsertAsync(Order order, CancellationToken cancellationToken = default)

Parameters

NameDescription

order Order

The entity.

cancellationToken CancellationToken

(Optional) A token that allows processing to be cancelled.

Returns

NameDescription

An asynchronous result that yields the insert.

InsertResourceAsync(int, Resource)

Asynchronously insert the given resource in the repository for the specified order.

public Task<Order> InsertResourceAsync(int orderId, Resource document)

Parameters

NameDescription

orderId int

The order primary key.

document Resource

The resource to add.

Returns

NameDescription

A task that represents the asynchronous insert operation. The task result contains the Order for the given

QueryProductsAsync(int, string, string, string, string, int?, int?, CancellationToken)

Asynchronously query a list of ProductOrder for a given order.

public virtual Task<List<ProductOrder>> QueryProductsAsync(int orderId, string select = null, string filter = null, string orderBy = null, string includeProperties = "", int? skip = null, int? take = null, CancellationToken cancellationToken = default)

Parameters

NameDescription

orderId int

Specifies the order id.

select string

(Optional) Specifies a select expression.

filter string

(Optional) Specifies the filter expression.

orderBy string

(Optional) Order by expression.

includeProperties string

(Optional) A comma separated list of nested entity names to retrieve.

skip int?

(Optional) The number of records to skip before the first record found.

take int?

(Optional) The number of records to take after the first record found.

cancellationToken CancellationToken

(Optional) A token that allows processing to be cancelled.

Returns

NameDescription

A task that represents the asynchronous get operation.

Last updated