This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi, Here's a sample of my code:
Query qry = new Query(typeof(InventoryItemCheckoutHistory), Entity.Attribute("InventoryItemSampleId") == Id); qry.Order = Order.By("CreatedOn").Descending(); qry.Page.LimitTo(1); var results = uow.Find(qry); I am trying to get the last InventoryItemCheckoutHistory persisted to the db. Hence the order by and limit criteria. However, having the LimitTo() causes an exception: Object reference not set to an instance of an object. If I remove the LimitTo() it works fine but I get back too many records, I just want the latest one. Any clues as to what might be causing this? Thanks. |
|
|
LimitTo is used to derive a new paging specification from an existing one. (Note also that it returns a new Page, rather than modifying the one it is applied to.) To create a paging specification, use the static Limit method: query.Page = Page.Limit(1); |
|