Click or drag to resize

DbStoredProcImageAccessor Constructor (GetConnectionCallback, Boolean, String, String, IDictionary)

Construct an accessor that can access images in a database via stored procedures

Namespace:  Atalasoft.Imaging.ImageSources.Data
Assembly:  Atalasoft.dotImage (in Atalasoft.dotImage.dll) Version: 11.0.0.0.0.297 (.NET 4.5.2, x86)
Syntax
public DbStoredProcImageAccessor(
	GetConnectionCallback getConnection,
	bool encryptSerializedState,
	string getImageByIndexProc,
	string getImageStreamCountProc,
	IDictionary extraParameters
)

Parameters

getConnection
Type: Atalasoft.Imaging.ImageSources.DataGetConnectionCallback
A delegate that can return connections to the database. This accessor must be able to be serialized, so make the delegate to a static method. If this accessor is used in an imagesoruce that is used in ASP.NET controls, then it will be serialized.
encryptSerializedState
Type: SystemBoolean
Set to true if you want the serialized state of this accessor to be encrypted. You must set the Encryptor and Decryptor properties to handle the decryption and encryption. The extraParameters are not encrypted when serialized.
getImageByIndexProc
Type: SystemString
The name of a stored procedure that can get an image by index. It should take an int parameter called "@index" and any other parameters you need, and return the image stream at that index. index is not a primary key into your table, but instead is a number in range of 0 to count-1, where count is gotten by calling the stored procedure named in the getImageStreamCountProc argument. If you take any extra parameters (aside from the index), you should specify their values by using the extraParameters argument. The stored procedure should result in a single row dataset where the first column is the image. It can either be an encoded image in a varbinary or image field or a string. If it is a string it is interpreted as a filename, which will be opened to get to the images.
getImageStreamCountProc
Type: SystemString
The name of a stored procedure that can get the number of image streams. There are no required parameters. The stored procedure should result in single row dataset with the count in the first column. If you need any extra parameters, you should specify their values by using the
extraParameters
argument.
extraParameters
Type: System.CollectionsIDictionary
The parameters that are passed to all of your stored procedures. For SqlCommands, the keys should be strings which are the names of the parameters and start with an @. For OleDbCommands, you must use a IDictionary with sorted keys (e.g. SortedList) and use index numbers (starting at 0) as keys. The parameters are added in the sort order of the keys. The values can be any object that can be automatically converted by the IDbDataParameter for your connection. The extraParameters are not encrypted when this object is serialized. A copy of the the dictionary will be made upon construction, so that changes to it will not affect this object.
Remarks
Here are some sample stored procedures that would work to get images from an table called images, where the data was stored in an field called imageData. Here is a stored procedure that would meet the specification for the getImageByIndexProc. @startId and @endId are extra parameters that would need to be passed in to the constructor.
create PROCEDURE GetImageByIndex
    @index int, @startId int, @endId int
as
    set nocount on;
    with istr as (
        select id, imagedata, row_number() over (order by id) as rn 
        from images where id between @startid and @endid
    ) select imageData from istr where rn=(@index+1)
Here is a stored procedure that would meet the specification for the getImageStreamCountProc. @startId and @endId are extra parameters that would need to be passed in to the constructor.
create PROCEDURE GetImageStreamCount
    @startid int, @endid int
as
    set nocount on;
    select count(*) from images where id between @startid and @endid
Note: the extra parameters must be the same for all stored procedures.
See Also