public virtual DBCommandResult <T> Select(DBCommand <T> aCommand, CachePreference aCachePreferences) { int _count = Count(aCommand, aCachePreferences); List <T> _data = GetData(aCommand, aCachePreferences); return(new DBCommandResultImpl <T>(_data, _count, aCommand.Pager)); }
public int Count <T>(SqlCriteria aCriteria, CachePreference aPreferences) where T : class, new() { int count = 0; var query = QueryFactory.CreateSelectQuery(); query.SetStatement( s => { s.AddField(Factory.GetExpressionHelper <T>().GetCountField <T>()); s.AddFrom(Loader.GetClassMap <T>().GetTableName()); }); if (aCriteria == null) { aCriteria = Factory.CreateCriteria(); } if (aPreferences == null) { aPreferences = new CachePreferenceImpl(); } query.SetCriteria(aCriteria).SetCache(aPreferences); IntBinder binder = new IntBinder(); binder.OnBind = delegate(IntResult aResult) { count = aResult.value; }; Connetion.execute(query, binder); return(count); }
public virtual DataTable GetDByCriteria(SqlCriteria aCriteria = null, CachePreference aCachePreferences = null, OnRowSelect onSelect = null) { if (aCriteria == null) { aCriteria = GetCriteria(); } return(ExecuteSelectQuery(GetQuery(aCachePreferences).SetCriteria(aCriteria), onSelect)); }
public virtual int Count(DBCommand <T> aCommand, CachePreference aCachePreferences) { var _query = GetQuery(aCachePreferences); var _criteria = _query.GetCriteria(); ApplyFiltersForCriteria(_criteria, aCommand); return(GetCount(_criteria)); }
public T GetById <T>(Object anID, CachePreference aPreferences = null) where T : class, new() { T data = new T(); ClassMap <T> classmap = Loader.GetClassMap <T>(); IdentityMap identity = classmap.Identity; ValueExtractor.SetValue(identity.Member.Name, data, anID); return(Select <T>(GetQuery <T>(aPreferences).SetMaximum(1).SetCriteria(GetByIdCriteria <T>(data)), null).Single()); }
private SelectQuery <T> GetQuery <T>(CachePreference aPreferences) where T : class, new() { if (aPreferences == null) { aPreferences = new CachePreferenceImpl(); } return(Factory.GetQueryFactory().CreateSelectQuery <T>().SetCache(aPreferences)); }
public virtual List <T> Get(SqlCriteria aCriteria = null, CachePreference aCachePreferences = null, OnEntitySelect <T> onSelect = null) { if (aCriteria == null) { aCriteria = GetCriteria(); } return(ExecuteSelectQuery(GetQuery(aCachePreferences).SetCriteria(aCriteria), onSelect)); }
public SelectQuery <T> GetQuery(CachePreference aPreference) { if (aPreference == null) { aPreference = new CachePreferenceImpl(); } return(factory.GetQueryFactory().CreateSelectQuery <T>().SetCache(aPreference)); }
public T GetSingle <T>(SqlCriteria aCriteria, CachePreference aPreferences) where T : class, new() { if (aCriteria == null) { aCriteria = Factory.CreateCriteria(); } var _results = Select <T>(GetQuery <T>(aPreferences).SetCriteria(aCriteria).SetMaximum(1), null); return(_results.Count > 0 ? _results.First() : null); }
private List <T> GetData(DBCommand <T> aCommand, CachePreference aCachePreferences) { var _query = GetQuery(aCachePreferences); var _criteria = _query.GetCriteria(); ApplyFiltersForCriteria(_criteria, aCommand); ApplyOrderForQuery(_criteria, aCommand); ApplyPagerForQuery(_query, aCommand); return(ExecuteSelectQuery(_query, delegate(T aT, int index) { })); }
public virtual T GetById(object anId, CachePreference aCachePreferences) { T data = null; DBHelper.Execute( delegate(DbSession aSession) { data = aSession.GetById <T>(anId, aCachePreferences); }); return(data); }
public virtual T GetSingle(SqlCriteria aSqlCriteria, CachePreference aCachePreference) { T data = null; DBHelper.Execute( delegate(DbSession aSession) { data = aSession.GetSingle <T>(aSqlCriteria, aCachePreference); }); return(data); }
public virtual List <T> SelectList(DBCommand <T> aCommand, CachePreference aCachePreferences) { var _query = GetQuery(aCachePreferences); var _criteria = _query.GetCriteria(); ApplyFiltersForCriteria(_criteria, aCommand); ApplyOrderForQuery(_criteria, aCommand); if (aCommand.Pager != null && aCommand.Pager.RowCount > 0) { ApplyPagerForQuery(_query, aCommand); } return(ExecuteSelectQuery(_query, delegate(T aT, int index) { })); }
public void Add(string aKey, object aValue, AspNetNotication aNotification) { CacheSpec cacheSpecs = aNotification.GetCacheSpec(); CachePreference pref = cacheSpecs.GetCachePreferences(); cache.Add( aKey, aValue, aNotification.GetDependency(), DateTime.Now.AddSeconds(pref.CacheDuration), System.Web.Caching.Cache.NoSlidingExpiration, CacheItemPriority.Normal, new CacheItemRemovedCallback(this.CacheItemRemovedCallback) ); CachedKeys[aKey] = null; }
private int GetCount(SqlCriteria aCriteria = null, String aSqlQuery = null, CachePreference aCachePreferences = null) { int count = 0; if (aSqlQuery != null) { aCriteria.AddSql(aSqlQuery); } DBHelper.Execute( delegate(DbSession aSession) { count = aSession.Count <T>(aCriteria, aCachePreferences); }); return(count); }
private IExecutor GetExecuteQuery(HasCache aCache, HasMaximum aMaximum) { CachePreference pref = aCache.GetCachePreferences(); if (!pref.Cachable) { return(new DefaultExecutor()); } if (pref.CacheDuration <= 0) { return(new DefaultExecutor()); } if (!pref.IsCacheDependency) { return(new CacheExecutor(aCache.GetCachePreferences())); } return(new DependencyExecutor(aCache.GetCachePreferences(), aMaximum.GetMaximum())); }
public SelectQuery SetCache(CachePreference aCache) { preferences = aCache; return(this); }
public virtual DataTable GetDPager <E>(int aMinimum = 0, int aMaximum = 10, T aCriteriaModel = null, System.Linq.Expressions.Expression <Func <T, E> > aOrderBy = null, bool isAscending = true, String aSqlQuery = null, CachePreference aCachePreferences = null, OnRowSelect onSelect = null) { return(ExecuteSelectQuery(GetModelOrderQueryWithSql(aCriteriaModel, aOrderBy, isAscending, aSqlQuery, aCachePreferences).SetMaximum(aMaximum).SetMinimum(aMinimum), onSelect)); }
public virtual List <T> Get <E>(T aCriteriaModel = null, System.Linq.Expressions.Expression <Func <T, E> > aOrderBy = null, bool isAscending = true, CachePreference aCachePreferences = null, OnEntitySelect <T> onSelect = null) { return(ExecuteSelectQuery(GetModelOrderQueryWithSql(aCriteriaModel, aOrderBy, isAscending, null, aCachePreferences), onSelect)); }
public CacheExecutor(CachePreference aPreference) : base(aPreference) { }
public virtual List <T> GetTop <E>(int aTop, T aCriteriaModel = null, System.Linq.Expressions.Expression <Func <T, E> > aOrderBy = null, bool isAscending = true, String aSqlQuery = null, CachePreference aCachePreferences = null, OnEntitySelect <T> onSelect = null) { return(ExecuteSelectQuery(GetModelOrderQueryWithSql(aCriteriaModel, aOrderBy, isAscending, aSqlQuery, aCachePreferences).SetMaximum(aTop), onSelect)); }
public virtual int GetCount(T aCriteriaModel, String sqlQuery, CachePreference aCachePreferences) { return(GetCount(GetDataModelCriteria(aCriteriaModel, false), sqlQuery, aCachePreferences)); }
public virtual int GetCount(SqlCriteria aCriteria, CachePreference aCachePreferences) { return(GetCount(aCriteria, null, aCachePreferences)); }
public SelectQuery <T> SetCache(CachePreference aCache) { query.SetCache(aCache); return(this); }
public AbstractCacheExecutor(CachePreference aPreference) { CacheSpecs = new CacheSpecImpl(aPreference); Cache = Database.Current.Factory.GetCache(); Generator = Database.Current.Factory.GetKeyGenerator(); }
public SelectQuery() { preferences = new CachePreferenceImpl(); }
public T GetById <T>(T aModel, CachePreference aPreferences = null) where T : class, new() { var query = GetQuery <T>(aPreferences).SetMaximum(1).SetCriteria(GetByIdCriteria(aModel)); return(Select <T>(query, null).Single()); }
public List <T> Get <T>(SqlCriteria aCriteria = null, OnEntitySelect <T> onExecute = null, CachePreference aPreferences = null) where T : class, new() { if (aCriteria == null) { aCriteria = Factory.CreateCriteria(); } return(Select <T>(GetQuery <T>(aPreferences).SetCriteria(aCriteria), new TemplateBinder <T>(), onExecute)); }
protected SelectQuery <T> GetModelOrderQueryWithSql <E>(T aCriteriaModel, System.Linq.Expressions.Expression <Func <T, E> > aOrderBy, bool isAscending, String sqlQuery, CachePreference aCachePreferences = null) { var query = GetQuery(aCachePreferences).SetCriteria(GetDataModelCriteria(aCriteriaModel, false)); var criteria = query.GetCriteria(); if (!String.IsNullOrEmpty(sqlQuery)) { criteria.AddSql(sqlQuery); } if (aOrderBy != null) { if (!isAscending) { criteria.AddOrder(ExpressionHelper.OrderDes(aOrderBy)); } else { criteria.AddOrder(ExpressionHelper.OrderAsc(aOrderBy)); } } return(query); }
public virtual T GetSingle(T aCriteriaModel, bool isIdIncluded, CachePreference aCachePreference) { SqlCriteria _cri = GetDataModelCriteria(aCriteriaModel, isIdIncluded); return(GetSingle(_cri, aCachePreference)); }