ProductRepository

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

A product repository.

public class ProductRepository : GenericRepository<Product>, IProductRepository, IGenericRepository<Product>

Inheritance

objectGenericRepository<Product>ProductRepository

Implements

IProductRepository, IGenericRepository<Product>

Inherited Members

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

Constructors

ProductRepository(BabelDbContext)

Initializes a new instance of the ProductRepository class.

public ProductRepository(BabelDbContext context)

Parameters

NameDescription

The database context.

Methods

Delete(Product)

Deletes the given entity from the repository. Begins tracking the given entity in the Detached state such that it will be deleted in the database when SaveChanges() is called.

public override void Delete(Product product)

Parameters

NameDescription

product Product

The entity to delete to delete.

Delete(IEnumerable<int>)

Deletes a list of products 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> productsIds)

Parameters

NameDescription

productsIds IEnumerable<int>

The product primary key ids to delete.

DeleteProductLicenseTemplatesAsync(int, IEnumerable<int>)

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

public Task DeleteProductLicenseTemplatesAsync(int productId, IEnumerable<int> templatesIds)

Parameters

NameDescription

productId int

The product primary key.

templatesIds IEnumerable<int>

List of identifiers for the templates.

Returns

NameDescription

A task that represents the asynchronous delete operation.

DeleteProductReleaseAssemblyAsync(int, int, int)

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

public Task DeleteProductReleaseAssemblyAsync(int productId, int releaseId, int assemblyId)

Parameters

NameDescription

productId int

The product primary key.

releaseId int

The release primary key.

assemblyId int

The assembly primary key.

Returns

NameDescription

A task that represents the asynchronous delete operation.

DeleteProductReleaseAsync(int, int)

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

public Task DeleteProductReleaseAsync(int productId, int releaseId)

Parameters

NameDescription

productId int

The product primary key.

releaseId int

The release primary key.

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<Product> 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.

GetProductAssembliesAsync(int)

Asynchronously gets a list of assemblies for a given product.

public Task<List<Assembly>> GetProductAssembliesAsync(int productId)

Parameters

NameDescription

productId int

The product primary key.

Returns

NameDescription

A task that represents the asynchronous get operation. The task result contains a list of assembly found.

GetProductLicenseTemplatesAsync(int)

Asynchronously gets a list of license templates for the given product.

public Task<List<LicenseTemplate>> GetProductLicenseTemplatesAsync(int productId)

Parameters

NameDescription

productId int

The product primary key.

Returns

NameDescription

A task that represents the asynchronous get operation. The task result contains a list of license template

GetProductLicensesAsync(int)

Asynchronously gets a list of licenses for the given product.

public Task<List<License>> GetProductLicensesAsync(int productId)

Parameters

NameDescription

productId int

The product primary key.

Returns

NameDescription

A task that represents the asynchronous get operation. The task result contains a list of license found.

GetProductReleaseAssembliesAsync(int, int)

Asynchronously gets a list of assemblies for a given product and release.

public Task<List<Assembly>> GetProductReleaseAssembliesAsync(int productId, int releaseId)

Parameters

NameDescription

productId int

The product primary key.

releaseId int

The release primary key.

Returns

NameDescription

A task that represents the asynchronous get operation. The task result contains a list of assembly found.

GetProductReleaseAssemblyAsync(int, int, int)

Asynchronously gets the assembly for a given product release.

public Task<Assembly> GetProductReleaseAssemblyAsync(int productId, int releaseId, int assemblyId)

Parameters

NameDescription

productId int

The product primary key.

releaseId int

The release primary key.

assemblyId int

The assembly primary key.

Returns

NameDescription

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

GetProductReleaseAsync(int, int)

Asynchronously gets the release for the given product.

public Task<Release> GetProductReleaseAsync(int productId, int releaseId)

Parameters

NameDescription

productId int

The product primary key.

releaseId int

The release primary key.

Returns

NameDescription

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

GetProductReleasesAsync(int)

Asynchronously gets a list of releases for the given product.

public Task<List<Release>> GetProductReleasesAsync(int productId)

Parameters

NameDescription

productId int

The product primary key.

Returns

NameDescription

A task that represents the asynchronous get operation. The task result contains a list of release found.

Insert(Product)

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 void Insert(Product product)

Parameters

NameDescription

product Product

The entity to delete to delete.

Examples

using Babel.Data;

using UnitOfWork db = new UnitOfWork();

var products = await db.ProductRepository.GetAsync();
if (products.Count == 0)
{
    var product = new Babel.Data.Product {
        Name = "ACME",
        SignatureKeys = new Resource() {
            Name = "Product Keys",
            Data = File.ReadAllBytes("Keys.snk"),
            DataFormat = "SNK"
        }
    };

    await db.ProductRepository.InsertAsync(product);
    await db.SaveAsync();
}

InsertAsync(Product, 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<Product>> InsertAsync(Product product, CancellationToken cancellationToken = default)

Parameters

NameDescription

product Product

The entity to delete to delete.

cancellationToken CancellationToken

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

Returns

NameDescription

An asynchronous result that yields the insert.

InsertProductReleaseAssemblyAsync(int, Release, Assembly)

Asynchronously inserts the given release, assembly record in the repository for a specified product. Begins tracking the given entities, 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 Task<EntityEntry<ProductAssembly>> InsertProductReleaseAssemblyAsync(int productId, Release release, Assembly assembly)

Parameters

NameDescription

productId int

The product primary key.

release Release

The release primary key.

assembly Assembly

The assembly primary key.

Returns

NameDescription

A task that represents the asynchronous Insert operation. The task result contains the EntityEntry<

InsertProductReleaseAsync(int, Release)

Asynchronously inserts the given release record in the repository for a specified product. Begins tracking the given entities, 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 Task InsertProductReleaseAsync(int productId, Release release)

Parameters

NameDescription

productId int

The product primary key.

release Release

The release object to be inserted.

Returns

NameDescription

A task that represents the asynchronous Insert operation.

UpdateProductReleaseAssemblyAsync(int, Release, Assembly)

Asynchronously updates the given release, assembly record in the repository for a specified product. Begins tracking the given entities, and any other reachable entities that are not already being tracked, in the Updated state such that they will be updated into the database when SaveChanges() is called.

public Task<ProductAssembly> UpdateProductReleaseAssemblyAsync(int productId, Release release, Assembly assembly)

Parameters

NameDescription

productId int

The product primary key.

release Release

The release primary key.

assembly Assembly

The assembly primary key.

Returns

NameDescription

A task that represents the asynchronous Update operation. The task result contains the ProductAssembly

UpdateProductReleaseAsync(int, Release)

Asynchronously updates the given release record in the repository for a specified product. Begins tracking the given entities, and any other reachable entities that are not already being tracked, in the Updated state such that they will be updated into the database when SaveChanges() is called.

public Task UpdateProductReleaseAsync(int productId, Release release)

Parameters

NameDescription

productId int

The product primary key.

release Release

The release object to be updated.

Returns

NameDescription

A task that represents the asynchronous Update operation.

Last updated