New Posts New Posts RSS Feed: Finding most recent record
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Finding most recent record

 Post Reply Post Reply
Author
BillG View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 05-Dec-2007
Location: Monroe, MI
Posts: 233
Post Options Post Options   Quote BillG Quote  Post ReplyReply Direct Link To This Post Topic: Finding most recent record
    Posted: 27-Apr-2008 at 3:52pm
In SQL, I would use the MAX function to find the most recent case for a member.  Is there an easy way to do it with Entities and OQL or do I have to use a SQL query or stored procedure?
 
BillG
 
Back to Top
davidklitzke View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 14-Jun-2007
Posts: 715
Post Options Post Options   Quote davidklitzke Quote  Post ReplyReply Direct Link To This Post Posted: 29-Apr-2008 at 9:46am
Use a PassthroughRdbQuery,
Back to Top
pnschofield View Drop Down
Newbie
Newbie
Avatar

Joined: 14-Sep-2007
Location: United States
Posts: 18
Post Options Post Options   Quote pnschofield Quote  Post ReplyReply Direct Link To This Post Posted: 29-Apr-2008 at 9:51am
Try something like this:

RdbQuery query = new RdbQuery(typeof(Case));
query.AddClause(Case.MemberIdEntityColumn, EntityQueryOp.EQ, mMember.MemberID);
query.AddOrderBy(Case.CaseDate, ListSortDirection.Descending);
query.Top = 1;
Case mostRecentCase = PM.GetEntity<Case>(query);

When you sort the cases for a member by date, descending, the top 1 record will be the most recent.

Paul
Back to Top
pnschofield View Drop Down
Newbie
Newbie
Avatar

Joined: 14-Sep-2007
Location: United States
Posts: 18
Post Options Post Options   Quote pnschofield Quote  Post ReplyReply Direct Link To This Post Posted: 29-Apr-2008 at 9:52am
Simul-posted with David!

David, would the top-1 approach work?
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down