You need to add a reference to combit.ListLabel24.RedisDataProvider.dll and StackExchange.Redis (NuGet) in your project.
For a simple connection without any registered hash tables (for hash tables see below) you just need to create an instance of RedisDataProvider and specify the connection information in the constructor (options documentation: https://stackexchange.github.io/StackExchange.Redis/Configuration#configuration-options):
var provider = new RedisDataProvider.RedisDataProvider("<YourServerURL or IP>"); ListLabel ll = new ListLabel(); ll.DataSource = provider; ll.Design();
Because Redis is a key-value database, it does not have regular tables as you would expect from a schematized RDBMS. Every entry is a unique key, therefore in Redis, a table consists of many keys which belong to one table: e. g. "user:001", "user:002", ...
Since List & Label can't know how the database is structured and could only guess which key belongs to which table, you need to define the layout for every hash table you want to use.
This can be done easily by adding a new lambda to the RegisteredHashTables. If RegisteredHashTables contains any values, every database collection key will be delegated to the lambda. Then you can check with your own specified schema, if the delegated key belongs to any table. If it belongs to a table, you need to return the table name or String.Empty/null if the key does not match any table.
var provider = new RedisDataProvider.RedisDataProvider("<YourServerURL or IP>"); provider.RegisteredHashTables.Add((s) => { if (s.StartsWith("user")) return "user"; return null; });
For using Redis with the Report Server you need to add the data source "Redis" (under the category NoSQL). You need to at least specify the connection string for the data source (options documentation: https://stackexchange.github.io/StackExchange.Redis/Configuration#configuration-options).
If you want to use hash tables you need to specify the way the hash tables should be registered. For registering a hash table you must specify the value which the selected compare-function will check against and that will also be used as the table's name.
This configuration connects to the Redis server at 192.168.10.204, registers the hash tables "user" and "items" (separated by "|") and uses the value as input for the compare-function (Starts with) and as the resulting table name.
To make this example clearer, this configuration translated to code (simplified) would look like this:
var provider = new RedisDataProvider.RedisDataProvider("192.168.10.204"); // connection string provider.RegisteredHashTables.Add((s) => { if (s.StartsWith("user")) return "user"; return null; }); provider.RegisteredHashTables.Add((s) => { if (s.StartsWith("items")) return "items"; return null; });
The RedisDataProvider is IDisposable. Make sure to Dispose() the provider after usage. The sources for the provider are also available on our GitHub repository if you need to build against a different version.
Jochen Bartlau leads the development at combit as Managing Director. He's a Microsoft .NET enthusiast driving innovation & agile project management. The mobile devices geek who used to be a physicist in his first life loves to spend his spare time with his family.