Shawn L
Shawn L

Reputation: 21

Servicestack Deserialize Redis Response GetAllItemsFromList

So using lists within Servicestack/Redis, when pulling them back from the server I am getting a list of strings (which each the same CLASS just different data in each one).

I did not see a way of using "typed" lists which would allow Servicestack to serialize/deserialize as I add, get items from the List. So my question is:

List<string> resp = rc.GetAllItemsFromList (key);

Gives me back a LIST (Collection) of strings. Each one being a JSON representation of Class ABC.

I'd rather have a list of <ABC> returned. If not, I know I can iterate through the collection of strings deserializing each. But want to know if there is a better way to be doing this than that.

Upvotes: 2

Views: 138

Answers (1)

mythz
mythz

Reputation: 143399

To get a List of Types back you'd use the IRedisTypedClient API and access the Typed List APIs in IRedisList by accessing the Lists[] collection, e.g:

var redisAbc = redis.As<Abc>();
List<Abc> results = redisAbc.Lists[key].GetAll();

Upvotes: 1

Related Questions