Våra sajter
Litium Studio Knowledgecenter

Knowledge Center för Litium Studio

Litium Scensum Knowledge Center

Knowledge Center för Litium Scensum

Litium Partner

Återfinns information som partner till Litium.

Support

Extending a repository

The repositories in Scensum are responsible for executing stored procedures and uses data mappers to map data result sets to business objects.

Create class

Extend the appropriate Repository class.

C#
public ExtendedProductRepository : ProductRepository

Override method

C#
public override IProduct GetById(int channelId, int productId) 
{ 
    IDataParameter[] parameters = { 
        ParameterHelper.CreateParameter("@ProductId", productId, SqlDbType.Int),
        ParameterHelper.CreateParameter("@ChannelId", channelId, SqlDbType.Int) 
    }; 
    
    DatabaseSetting dbSettings = new DatabaseSetting("ExtendedProductRepository.GetById");
    using (IDataReader dataReader = new DataHandler().ExecuteSelect("[product].[pExtendedProductGetById]", parameters, dbSettings)) 
    { 
        return CreateDataMapper(dataReader).ReadRow();
    } 
}

Modify the IoC settings file

Repository instances are managed by the IoC container. To get the IoC container to create an instance of your extended repository, the type definition in the IoC settings file needs to be modified.

XML
<component
id="ProductRepository"
service="Litium.Scensum.Product.Repository.ProductRepository, Litium.Scensum.Product"
type="YourProject.ExtendedProductRepository, YourProject" />