internal bool UpdateBlobToDiscIfNeeded(object entity, object id, object[] currentState, object[] previousState, string[] propertyNames, IType[] types)
        {
            bool res = false;

            var result = from t in types.Select((n, index) => new { Type = n, Index = index }) where t.Type.ReturnedClass.Equals(_BLOB) select t.Index;

            foreach (var el in result)
            {

                object o = (currentState == null) ? null : currentState[el];
                object p = (previousState == null) ? null : previousState[el];
                bool needtocleanold = (p != null);

                if (object.ReferenceEquals(o, p))
                    continue;

                if (o != null)
                {
                    res = true;
                    IPersistentBufferProvider IBP = o as IPersistentBufferProvider;

                    if (IBP.IsPersistent)
                        needtocleanold = false;
                    else
                    {
                        if (!IBP.Save( _Tx.Folders.GetPrivatePath()))
                        {
                            //rollback if save as failed
                            currentState[el] = p;
                            needtocleanold = false;
                        }
                        else
                        {
                            IBP.IsPersistent = true;
                            File.SetAttributes(IBP.PersistedPath, File.GetAttributes(IBP.PersistedPath) | (FileAttributes.Hidden | FileAttributes.Archive |
                                                                                         FileAttributes.ReadOnly));

                            NewFiles.Add(IBP.PersistedPath);
                        }
                    }


                }

                if (needtocleanold)
                {
                    IPersistentBufferProvider old = previousState[el] as IPersistentBufferProvider;
                    if (old.IsPersistent)
                        OldFiles.Add(old.PersistedPath);
                }

            }

            return res;
        }