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); }); }
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)); }
public void Key <T>(params string[] names) where T : Bean, new() { Key(Bean.GetKind <T>(), names); }
public void Key <T>(string name, bool autoIncrement) where T : Bean, new() { Key(Bean.GetKind <T>(), name, autoIncrement); }
public T Load <T>(params object[] compoundKey) where T : Bean, new() { return(Load <T>(KeyUtil.PackCompoundKey(Bean.GetKind <T>(), compoundKey))); }
public T Load <T>(object key) where T : Bean, new() { return(RowToBean <T>(_storage.Load(Bean.GetKind <T>(), key))); }
public long Count <T>(bool useCache, string expr = null, params object[] parameters) where T : Bean, new() { return(Count(useCache, Bean.GetKind <T>(), expr, parameters)); }
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>)); }
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))); }
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()); }