public object Proxy(object entity, Func <object, object> subProxyHandler)
        {
            var metadata = RepositoryFramework.GetDefineMetadata(entity.GetType());

            var proxy   = entity;
            var proxyed = false;

            if (!ProxyProvider.IsProxy(entity) && metadata.ClassJoinDefines.Count > 0)
            {
                proxy = ProxyProvider.CreateEntityProxy(metadata.EntityType);
                metadata.MergeData(entity, proxy);
                proxyed = true;
            }

            var pa = PropertyAccessorFactory.GetPropertyAccess(metadata.EntityType);

            foreach (var property in metadata.CascadeProperties)
            {
                if (EntityInterceptor.PropertyInited(entity, property.Name))
                {
                    var value = pa.GetGetter(property.Name).Get(entity);
                    if (value != null)
                    {
                        var valueProxy = subProxyHandler(value);
                        if (valueProxy != value || proxyed)
                        {
                            pa.GetSetter(property.Name).Set(proxy, valueProxy);
                        }
                    }
                }
            }

            return(proxy);
        }
        public static bool PropertyInited(object entity, string member)
        {
            var proxy = entity as IProxyTargetAccessor;

            if (proxy != null)
            {
                EntityInterceptor ei = (EntityInterceptor)proxy.GetInterceptors().FirstOrDefault(o => o.GetType() == typeof(EntityInterceptor));
                if (ei != null)
                {
                    return(ei.PropertyInited(member));
                }
            }
            return(true);
        }