DBDownloader
This class provides functionality for downloading data from a database and storing the result in a provided class. It supports multithreaded asynchronous calls, and allows for a queue of threaded download operations. It has automatic retry capability built in.
The type of DB Connection passed determines the database language it uses. You could for example provide a MySql connection instead.
It's like saying, "Hey downloader, I have a class with several properties I want filled from my database, take care of the rest".
Quick implementation
Downloader Extension
There is an easy way to create the DBDownloader by using the static extension method.
Assign / AssignSingle
Assigns the downloaded data to a property of the base object. Can be called multiple times using fluent syntax to fill multiple properties. The downloader automatically manages the multithreaded and asyhcnronous operations for filling each property.
It uses Dapper behind the scenes to perform the mapping and query execution. If you want to supply parameters, you can use the object
Param
parameter.
If you're not assigning a list, but a single object, use AssignSingle()
.
Example:
Wait
Waits for all download tasks to complete. This can be called inline or later right before the downloaded data is required. It is thread blocking.
Example:
GetDownloadTime
Gets the total time taken for all download tasks to complete.
Example:
Downloads
You can get to the list of tasks created by accessing this property.
Every DownloadResult has properties for the success boolean, if an exception was thrown, the name of the property it set, and dates to indicate start and end times.
Last updated