예제 #1
0
        public void Trash(Bean bean)
        {
            EnsureDispensed(bean);

            if (bean.GetKey(_keyAccess) == null)
            {
                return;
            }

            ImplicitTransaction(delegate() {
                bean.BeforeTrash();
                foreach (var observer in _observers)
                {
                    observer.BeforeTrash(bean);
                }

                _storage.Trash(bean.GetKind(), bean.GetKey(_keyAccess));

                bean.AfterTrash();
                foreach (var observer in _observers)
                {
                    observer.AfterTrash(bean);
                }

                return(true);
            });
        }
예제 #2
0
        public object Store(Bean bean)
        {
            EnsureDispensed(bean);

            ImplicitTransaction(delegate() {
                bean.BeforeStore();
                foreach (var observer in _observers)
                {
                    observer.BeforeStore(bean);
                }

                var key = _storage.Store(bean.GetKind(), bean.Export(), DirtyTracking ? bean.GetDirtyNames() : null);
                if (key is CompoundKey)
                {
                    // compound keys must not change during insert/update
                }
                else
                {
                    bean.SetKey(_keyAccess, key);
                }

                bean.AfterStore();
                foreach (var observer in _observers)
                {
                    observer.AfterStore(bean);
                }

                return(true);
            });

            bean.ForgetDirtyBackup();
            return(bean.GetKey(_keyAccess));
        }
예제 #3
0
 public void Key <T>(params string[] names) where T : Bean, new()
 {
     Key(Bean.GetKind <T>(), names);
 }
예제 #4
0
 public void Key <T>(string name, bool autoIncrement) where T : Bean, new()
 {
     Key(Bean.GetKind <T>(), name, autoIncrement);
 }
예제 #5
0
 public T Load <T>(params object[] compoundKey) where T : Bean, new()
 {
     return(Load <T>(KeyUtil.PackCompoundKey(Bean.GetKind <T>(), compoundKey)));
 }
예제 #6
0
 public T Load <T>(object key) where T : Bean, new()
 {
     return(RowToBean <T>(_storage.Load(Bean.GetKind <T>(), key)));
 }
예제 #7
0
 public long Count <T>(bool useCache, string expr = null, params object[] parameters) where T : Bean, new()
 {
     return(Count(useCache, Bean.GetKind <T>(), expr, parameters));
 }
예제 #8
0
 public IEnumerable <T> FindIterator <T>(string expr = null, params object[] parameters) where T : Bean, new()
 {
     return(RowsIterator(Bean.GetKind <T>(), expr, parameters).Select(_crud.RowToBean <T>));
 }
예제 #9
0
 public T FindOne <T>(bool useCache, string expr = null, params object[] parameters) where T : Bean, new()
 {
     return(_crud.RowToBean <T>(Row(useCache, Bean.GetKind <T>(), expr, parameters)));
 }
예제 #10
0
 public T[] Find <T>(bool useCache, string expr = null, params object[] parameters) where T : Bean, new()
 {
     return(Rows(useCache, Bean.GetKind <T>(), expr, parameters).Select(_crud.RowToBean <T>).ToArray());
 }