public IEnumerable <DataItem> Update(IEnumerable items)
        {
            Dictionary <string, object> dic = new Dictionary <string, object>();

            foreach (var item in items)
            {
                string key = Metadata.GetCacheKey(item);
                dic[key] = item;
            }
            List <DataItem> newItems = new List <DataItem>();

            foreach (var data in Datas)
            {
                object di;
                if (dic.TryGetValue(data.Key, out di))
                {
                    data.Loaded = true;
                    data.Data   = di;

                    newItems.Add(data);
                }
            }
            return(newItems);
        }
        public void Process(IInvocation invocation, ClassDefineMetadata metadata)
        {
            if (metadata == null)
            {
                throw new ArgumentNullException("metadata");
            }

            if (metadata.IsCacheable)
            {
                IEnumerable ids = (IEnumerable)invocation.Arguments[1];

                var cache = RepositoryFramework.GetCacher(metadata);

                var idKeys = ids.Cast <object>().Distinct().Select(o => new IdKey(o, metadata.GetCacheKeyById(o)));

                //访问缓存并获取不在缓存中的 CacheKey
                IEnumerable <string> missing;
                //var cacheItems = cache.GetBatch<CacheData>(idKeys.Select(o => o.Key), out missing).Select(o => o.Convert(metadata.EntityType)).ToList();
                var cacheItems = cache.GetBatch(metadata.EntityType, idKeys.Select(o => o.Key), out missing).Cast <object>().ToList();

                if (missing.Count() > 0)
                {
                    var missIds = missing.Select(o => idKeys.First(ik => ik.Key == o).Id);
                    invocation.SetArgumentValue(1, missIds);

                    using (MonitorContext.Repository(invocation.Method))
                        invocation.Proceed();

                    var sourceItems = ((IEnumerable)invocation.ReturnValue).Cast <object>();

                    cacheItems.AddRange(sourceItems);

                    if (sourceItems.Count() > 0)
                    {
                        //加入缓存
                        cache.SetBatch(sourceItems.Select(o => new CacheItem <object>(metadata.GetCacheKey(o), metadata.CloneEntity(o))), 1200);
                    }
                    else
                    {
                        if (ProfilerContext.Current.Enabled)
                        {
                            ProfilerContext.Current.Trace("platform", String.Format("missing get list for null\r\n{0}", String.Join(",", missing)));
                        }
                    }
                }
                else
                {
                    using (MonitorContext.Repository(invocation.Method, true))
                    {
                    }
                }

                var ta       = TypeAccessor.GetAccessor(metadata.EntityType);
                var idGetter = ta.GetPropertyGetter(metadata.IdMember.Name);

                //按ID排序并进行类型转化
                invocation.ReturnValue = cacheItems
                                         .OrderBy(entity => idGetter(entity), ids.Cast <object>())
                                         .Cast(metadata.EntityType);

                //按ID排序并进行类型转化
                invocation.ReturnValue = cacheItems
                                         .OrderBy(entity => idGetter(entity), ids.Cast <object>())
                                         .Cast(metadata.EntityType);
            }
            else
            {
                using (MonitorContext.Repository(invocation.Method))
                    invocation.Proceed();
            }
        }