コード例 #1
0
        private void PersistCascade(object entity)
        {
            var service = TypeService.Instance;
            var type    = service.GetRealType(entity);
            var props   = service.GetCascadingPersistProperties(type);

            foreach (var prop in props)
            {
                PropertyUtil.ProcessProperty(
                    entity,
                    prop,
                    null,
                    null,
                    (kind, value, key) => {
                    if (value != null)
                    {
                        var valueType = service.GetRealType(value);
                        if (service.IsEntityDefined(valueType))
                        {
                            var valueEntity = service.AsEntity(value);
                            if (valueEntity != null)
                            {
                                Persist(value);
                            }
                        }
                    }
                    if (key != null)
                    {
                        var keyType = service.GetRealType(key);
                        if (service.IsEntityDefined(keyType))
                        {
                            var keyEntity = service.AsEntity(key);
                            if (keyEntity != null)
                            {
                                Persist(key);
                            }
                        }
                    }
                }
                    );
            }
        }