public List <Van> GetAllVans() { var vanDetailEntities = new EntityCollection <VanDetailsEntity>(); using (IDataAccessAdapter myAdapter = PersistenceLayer.GetDataAccessAdapter()) { myAdapter.FetchEntityCollection(vanDetailEntities, null); } return(_mapper.MapMultiple(vanDetailEntities).ToList()); }
public List <Van> GetVans(string vanName) { var vanDetailEntities = new EntityCollection <VanDetailsEntity>(); using (IDataAccessAdapter myAdapter = PersistenceLayer.GetDataAccessAdapter()) { IRelationPredicateBucket bucket = new RelationPredicateBucket(VanDetailsFields.Name % ("%" + vanName + "%")); myAdapter.FetchEntityCollection(vanDetailEntities, bucket); } return(_mapper.MapMultiple(vanDetailEntities).ToList()); }
internal EntityCollection <TEntity> Fetch(IDataAccessAdapter adapter, SortExpression sortExpression, ExcludeIncludeFieldsList excludedIncludedFields, IPrefetchPath2 prefetchPath, IRelationPredicateBucket predicateBucket, int pageNumber, int pageSize, int limit, out int totalItemCount) { var entities = new EntityCollection <TEntity>(new TEntityFactory()); totalItemCount = adapter.GetDbCount(entities, predicateBucket); if (limit > 0) { adapter.FetchEntityCollection(entities, predicateBucket, limit, sortExpression, prefetchPath, excludedIncludedFields); } else { adapter.FetchEntityCollection(entities, predicateBucket, 0, sortExpression, prefetchPath, excludedIncludedFields, pageNumber, pageSize); } return(entities); }
public void GetConfigurationValueReturnsEpochDateWhenEpochNameSettingGiven() { Expect.Call(_persistenceLayer.GetDataAccessAdapter()).Return(_dataAccessAdapter); Expect.Call(() => _dataAccessAdapter.FetchEntityCollection(null, null)).IgnoreArguments(). Callback(new FetchEntityCollectionDelegate(FetchEntityCollection)); Expect.Call(_dataAccessAdapter.Dispose); _mocks.ReplayAll(); string epochDateString = _repository.GetConfigurationValue(ConfigurationSettingName.EpochDate); _mocks.VerifyAll(); var epochDate = DateTime.Parse(epochDateString); Assert.AreEqual(DateTime.Parse(_expectedDateString), epochDate); }
internal EntityCollection <TEntity> Fetch(IDataAccessAdapter adapter, SortExpression sortExpression, ExcludeIncludeFieldsList excludedIncludedFields, IPrefetchPath2 prefetchPath, IRelationPredicateBucket predicateBucket, int pageNumber, int pageSize, int limit, int cacheTimeInSeconds, out int totalItemCount) { var qf = new QueryFactory(); var q = qf.Create().Select(qf.Create <TEntity>().Where(predicateBucket.PredicateExpression).CountRow()); if (cacheTimeInSeconds > 0) { q = q.CacheResultset(cacheTimeInSeconds); } totalItemCount = adapter.FetchScalar <int>(q); var entities = new EntityCollection <TEntity>(new TEntityFactory()); var parameters = new QueryParameters { CollectionToFetch = entities, FilterToUse = predicateBucket.PredicateExpression, RelationsToUse = predicateBucket.Relations, SorterToUse = sortExpression, ExcludedIncludedFields = excludedIncludedFields, PrefetchPathToUse = prefetchPath, CacheResultset = cacheTimeInSeconds > 0, CacheDuration = cacheTimeInSeconds > 0 ? TimeSpan.FromSeconds(cacheTimeInSeconds) : TimeSpan.Zero, RowsToTake = limit > 0 ? limit : pageSize, RowsToSkip = limit > 0 ? 0 : pageSize * (pageNumber - 1) }; adapter.FetchEntityCollection(parameters); return(entities); }
private EntityCollection <ClinicLogBookEntity> GetClinicLogBooks(Guid clinicPk, DateTime visitDate, string environment) { var filter = new RelationPredicateBucket(); filter.PredicateExpression.Add(ClinicLogBookFields.ClinicPk == clinicPk); filter.PredicateExpression.AddWithAnd(ClinicLogBookFields.SvcDate == visitDate.Date); var myCollection = new EntityCollection <ClinicLogBookEntity>(); try { using (IDataAccessAdapter adapter = AdapterFactory.CreateAdapter(MyNameSpace, environment)) { adapter.FetchEntityCollection(myCollection, filter, 0, null, null, null); } } catch (Exception) { throw; } return(myCollection); }
protected void ExpectLinqFetchEntityCollection() { Expect.Call(_dataAccessAdapter.FunctionMappings).Return(new FunctionMappingStore()); Expect.Call(() => _dataAccessAdapter.FetchEntityCollection(null, null, 0, null, null, null, 0, 0)). IgnoreArguments(); }