I have a function to query a set of records from a database:
public IQueryable<PointTransactionViewModel> GetPointTransactions(int UserID) { return ( from PointTransaction p in entities.PointTransaction join ActivityLog a in entities.ActivityLog on p.TransactionID equals a.TransactionID where p.UserID == UserID select new PointTransactionViewModel { ID = p.TransactionID, Balance = p.Balance, Points = p.Amount, RelatedActivityID = a.ID, When = p.When, Sender = p.SenderUserInfo.CompleteName } ); }
I want to add an additional reason, for example
var entries = GetPointTransaction(1); return entries.OrderbyDescending.Where( x => x.When >= start && w.When <= end). ( x => x.When);
However, it seems to me that I need to create a new request from the existing one for this to work. But it seems that I work before that without creating a new request in the code snippet before:
public PaginatedList(IQueryable<T> source, int pageIndex, int pageSize) { PageIndex = pageIndex; PageSize = pageSize; TotalCount = source.Count(); TotalPages = (int)Math.Ceiling(TotalCount / (double)PageSize); this.AddRange(source.Skip(PageIndex * PageSize).Take(PageSize)); }
Is there any code that somehow doesn't need to create a new query for the original IQueryable object? Is a temporary object created?
Edit
Strange, but to make it work, I have to do the following:
IQueryable<ActivityLogEntry> log = activityRepo.GetPointTransaction(userID). Where(x => x.PointsEarned == 50); return log.ToList();
The following actions will not be performed:
var log = = activityRepo.GetPointTransaction(userID); log.Where( x => x.PointsEarned == 50); return log.ToList();
There is no error message, so the where clause is apparently ignored (it also returns all data for which PointsEarned is not 50)