Click or drag to resize

DbStoredProcImageAccessor Constructor (GetConnectionCallback, Boolean, String, 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,
	string getFrameCountByIndexProc,
	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.
getFrameCountByIndexProc
Type: SystemString
The name of a stored procedure that can get the frame count of an image stream by index. It should take an int parameter called "@index" and any other parameters you need, and return the frame count 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 frame count. If you cannot provide this argument, you can pass null, and the frame count will be determined by decoding the image stream gotten with the
getImageByIndexProc
. Providing this argument can substantially speed up viewing of multi-framed images because viewers can know which images are visible without accessing the stream. A copy of the the dictionary will be made upon construction, so that changes to it will not affect this object.
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
and the frame count was stored in field called
frameCount
. 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
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 GetFrameCountByIndex
    @index int, @startId int, @endId int
as
    set nocount on;
    with istr as (
        select id, frameCount, row_number() over (order by id) as rn 
        from images where id between @startid and @endid
    ) select frameCount from istr where rn=(@index+1)
Note: the extra parameters must be the same for all stored procedures.
See Also