Using Servicestacks c# redis client how do I set the URN? -
i have code like:
public vehicle neworupdate(vehicle vehicle) { try { redismanager.execas<vehicle>(r => { r.store(vehicle); //save new or update }); } catch (exception ex) { errormessage = ex.tostring(); haserror = true; throw; } return vehicle; }
how can set urn item being added? see createurn extension on object don't see way set explicitly. default creates urn of "urn:vehicle:id". id have urn "urn:vehicles-{myspecialid}:id" possible control this?
or way ask this... can make own urn objects store?
vehicle v = new vehicle(); v.createurn = "urn:mine"; redismanager.execas<vehicle>(r => { r.store(v); });
it looks it's not hard, if know look. create list urn want:
string urn = string.format("urn:dealer:{0}:vehicles", dealer.dealerid); var vehicleclient = client.as<vehicle>(); var vehiclelist = vehicleclient.lists[urn]; foreach (var vehicle in dealer.vehicles) { vehiclelist.add(vehicle); }
add items custom list, , items can recalled using:
list<vehicle> returnvalue = new list<vehicle>(); string urn = string.format("urn:dealer:{0}:vehicles",dealerid); using (var client = new redisclient("192.168.42.128", 6379)) { returnvalue = client.as<vehicle>().lists[urn].tolist(); }
Comments
Post a Comment