/// <summary> /// Retrieves collection of data objects. /// </summary> /// <returns> /// Collection of generic data objects. Empty collection is returned /// if no data objects found. /// </returns> protected IEnumerable <T> FindAllObjects <T, TEntity>() where T : DataObject where TEntity : EntityObject { return(FindObjects <T, TEntity>( SqlFormatHelper.FormatObjName(_entitySet))); }
protected IEnumerable <T> FindObjects <T, TEntity>(Expression <Func <TEntity, bool> > whereClause) where T : DataObject where TEntity : EntityObject { Debug.Assert(whereClause != null); // get objects query ObjectQuery <TEntity> query = _context.CreateQuery <TEntity>(SqlFormatHelper.FormatObjName(_entitySet)); // find objects IQueryable <TEntity> resultQuery = query.Where(whereClause); List <T> list = new List <T>(_FindObjects <T, TEntity>(resultQuery)); return(list.AsReadOnly()); }
/// <summary> /// Removes all data objects from object context. /// </summary> protected void RemoveAllObjects <TEntity>() where TEntity : EntityObject { // remove data object from cache //_context.Cache.Clear(); // remove entity objects from context // EF 1.0 does not support RemoveAll functionality // TODO: use entity SQL ObjectQuery <TEntity> query = _context.CreateQuery <TEntity>( SqlFormatHelper.FormatObjName(_entitySet)); foreach (TEntity entity in query) { _context.DeleteObject(entity); } }
/////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////// public ObjectQuery <TEntity> CreateDefaultQuery <TEntity>() { return(_context.CreateQuery <TEntity>( SqlFormatHelper.FormatObjName(_entitySet))); }