C# ServiceStack.Redis 操作对象List

    class Car
    {
        public Int32 Id { get; set; } 
        public String Name { get; set; }

        static void Main(string[] args)
        {
            RedisClient client = new RedisClient("127.0.0.1", 6379);
            client.FlushAll();
            client.ChangeDb(0);
            var IRCar = client.As<Car>();
            IRCar.DeleteAll();
            var c1 = new Car() { Id = 1, Name = "东风标致408" };
            IRCar.Store(c1);
            List list = new List();
            list.Add(c1);
            var c2 = new Car() { Id = 2, Name = "东风标致508" };
            list.Add(c2);
            var c3 = new Car() { Id = 3, Name = "东风标致308" };
            list.Add(c3);
            var c4 = new Car() { Id = 4, Name = "东风标致3008" };
            list.Add(c4);
            IRCar.StoreAll(list);
            var _list = IRCar.GetAll();
        }
    }

 

posted @ 2016-05-05 17:44  zslm___  阅读(4138)  评论(0编辑  收藏  举报