none
Find all recently edited rows RRS feed

  • Question

  • Gooday

    Is there a linq to sql query which will open all recently changed/edited or opened rows , for example a WHERE statment along these lines . So that i may carry on with current work instead of searching for them.

    SELECT

    WHERE GETDATE() - 7 (pulling down all the work I'v done in the last week)

     thanks

    rob


    rh
    Tuesday, September 6, 2011 4:36 AM

Answers

  • Assuming you have an insert and update date on the table, you could do something like this:

           var today = DateTime.Now;
    
            var rows = from m in db.MyTable
                        where m.InsertDate > today.AddDays(-7) ||  m.UpdateDate > today.AddDays(-7)
                         select m;
    
    
    



    Tom Overton
    • Marked as answer by robhare Tuesday, September 6, 2011 8:35 AM
    Tuesday, September 6, 2011 5:13 AM

All replies

  • The only way to do this is if your table has a datetime field in it, and that field is being updated when you insert/update the record (either through a trigger or a default value of the current datetime).  Are there datetime column(s) like this on the table?

     


    Tom Overton

    • Edited by Tom_Overton Tuesday, September 6, 2011 4:53 AM
    Tuesday, September 6, 2011 4:46 AM
  • Assuming you have an insert and update date on the table, you could do something like this:

           var today = DateTime.Now;
    
            var rows = from m in db.MyTable
                        where m.InsertDate > today.AddDays(-7) ||  m.UpdateDate > today.AddDays(-7)
                         select m;
    
    
    



    Tom Overton
    • Marked as answer by robhare Tuesday, September 6, 2011 8:35 AM
    Tuesday, September 6, 2011 5:13 AM