/// <summary>
        /// 获取给定对象的对象缓存键
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public string GetCacheKey(object entity)
        {
            if (entity == null)
            {
                throw new ArgumentNullException("entity");
            }

            return(GetCacheKeyById(EntityUtil.GetId(entity)));
        }
        public UniqueRaise(RaiseType raiseType, ClassDefineMetadata metadata, object entity, bool autoDisposed)
        {
            key       = String.Format("{0}:{1}:{2}", metadata.EntityType.FullName, EntityUtil.GetId(entity), raiseType);
            NotRaised = !WorkbenchUtil <string, bool> .GetValue(UniqueRaiseKey, key);

            if (NotRaised)
            {
                WorkbenchUtil <string, bool> .SetValue(UniqueRaiseKey, key, true);
            }

            AutoDisposed = autoDisposed;
        }
        IClassJoinCascadeProcessor GetProcessor()
        {
            if (!inited)
            {
                var pa = TypeAccessor.GetAccessor(typeof(TEntity));

                processor.KeyFunc     = (entity) => EntityUtil.GetId(entity);
                processor.JoinKeyFunc = (join) => EntityUtil.GetId(join);
                processor.JoinFunc    = (join) => (TJoin)pa.GetProperty(joinMetadata.JoinName, join);
                inited = true;
            }
            return(processor);
        }
        IClassJoinCascadeProcessor GetProcessor()
        {
            if (!inited)
            {
                var ta = TypeAccessor.GetAccessor(typeof(TEntity));

                processor.KeyFunc        = (entity) => EntityUtil.GetId(entity);
                processor.JoinKeyFunc    = (join) => EntityUtil.GetId(join);
                processor.JoinFunc       = (join) => (IList <TJoin>)ta.GetProperty(joinMetadata.JoinName, join);
                processor.SourceJoinFunc = (entity) => (IList <TJoin>)joinMetadata.DataProcesser.Process(entity);
                inited = true;
            }
            return(processor);
        }
示例#5
0
 public TEntity Get(object id)
 {
     return(Data.FirstOrDefault(o => EntityUtil.GetId(o) == id));
 }
示例#6
0
        public void Delete(TEntity entity)
        {
            var id = EntityUtil.GetId(entity);

            Data.RemoveAll(o => EntityUtil.GetId(o) == id);
        }