none
How to delete a record automatically after a perild RRS feed

  • Question

  • I want to delete a user's order within 1hour if he still did not pay.So how to use entityframework to do so or can i use an alternative way to achieve this ?I also have similar need:if a user post a comment that violate our website rules,he is not allowed to post any comments within 30 minutes.Some people give me a solution :to write some code in the application_start methold.but the problems is that if the user stay in our site for more than 1 hour without leaving,it will not work.
    Thursday, January 21, 2016 11:26 AM

Answers

  • Hi yang-ping,

    For the first question, I guess there isn't such way from EF to achieve it. We could specify an timespan for each order record and there should be one background worker thread exists to checking this field after a particular time. Or maybe you want to encapsulate the orderID, timespan along with action/lambda and queued it then consume this queue in the background Task factory.

    The second issue, you want to block user to post within 30 mins. I believe you could place a judgement code snippet before post saved.


    Please mark this as answer if it helps with this issue!


    Friday, January 22, 2016 5:54 AM

All replies

  • I want to delete a user's order within 1hour if he still did not pay.So how to use entityframework to do so or can i use an alternative way to achieve this ?I also have similar need:if a user post a comment that violate our website rules,he is not allowed to post any comments within 30 minutes.Some people give me a solution :to write some code in the application_start methold.but the problems is that if the user stay in our site for more than 1 hour without leaving,it will not work.

    Why do you think EF will help you with this? Are you using a DB currently with this application?

    Thursday, January 21, 2016 5:29 PM
  • Hi 周洋平,

    >>I want to delete a user's order within 1hour if he still did not pay. So how to use entityframework to do so or can i use an alternative way to achieve this ?  I also have similar need:if a user post a comment that violate our website rules, he is not allowed to post any comments within 30 minutes.

    According to description, you want to use entity framework to delete a record automatically after a perild. From my experience, entity frame can’t implement it. You could post your problem on asp.net forum if your application is a web application.

    Best regards,

    Cole Wu

    Friday, January 22, 2016 5:35 AM
    Moderator
  • Hi yang-ping,

    For the first question, I guess there isn't such way from EF to achieve it. We could specify an timespan for each order record and there should be one background worker thread exists to checking this field after a particular time. Or maybe you want to encapsulate the orderID, timespan along with action/lambda and queued it then consume this queue in the background Task factory.

    The second issue, you want to block user to post within 30 mins. I believe you could place a judgement code snippet before post saved.


    Please mark this as answer if it helps with this issue!


    Friday, January 22, 2016 5:54 AM