How to get last 10 mins records using linq?

Anil Kumar

I want to write LINQ query from last 10 mins inserted records from table. How do I write it? Please help me.

Below is my SQL query:

SELECT AccountNumber, OrderID,RechargeDate 
FROM    OrderItem OI
WHERE RechargeStatus = 'SUCCESS' 
  AND AccountNumber ='" + AccountNumber + "' and DateADD(minute, -10,getdate() ) < RechargeDate  AND OrderItemID <> " + OrderItemID + "";

Now, I want to rewrite the query above using LINQ.

Sateesh Pagolu

You need to use Where linq extension method.

db.OrderItems.Where(x=>x.RechargeStatus.Equals("SUCCESS") && 
                       x.AccountNumber == strAccountNumber &&
                       x.RechargeDate > DateTime.Now.AddMinutes(-10) &&
                       x.OrderItemID != OrderItemID )

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to get Last 10 records from OrmLite?

From Dev

How to skip last 2 records and get all other records with linq?

From Dev

How to get double records using LinQ?

From Dev

how to get latest distinct 10 records without null values using linq query

From Dev

How to get last 5 mins record from SQL database table?

From Dev

How to get last 5 mins record from SQL database table?

From Dev

how to get last 10 added records in sqlite table in iphone

From Dev

How to get last inserted records

From Dev

Retrieving 10 records at a time only using LINQ

From Dev

How can I iterate over the last 5 mins of my log file using bash

From Dev

How to restrict a user from submitting a form more than once in 10 mins using php

From Java

How to get the last N records in mongodb?

From Dev

How to get first and last records between groups?

From Dev

How to get first and last records between groups?

From Dev

How to get last records with conditions from SQLite?

From Dev

Spring Data JPA Java - get Last 10 records from query

From Dev

Spring Data JPA Java - get Last 10 records from query

From Dev

How to make a query for showing records where time is not more then 30 mins

From Dev

How to get user records who don't visited in last two months using mysql

From Dev

how to get the last insert ID in linq

From Dev

how to get the last insert ID in linq

From Dev

Calculate mins in Linq

From Dev

Using output keyword to get last inserted records in SQL server?

From Dev

Netezza get records last updated in last 5 minutes using a last modified time stamp column in the table?

From Dev

Update records using LINQ

From Dev

Check was 10 mins elapsed

From Dev

Get records from table and related related table using Linq to entity

From Dev

using linq to entity to get records based on related entity

From Dev

Using Linq to get records that have specific foreign key

Related Related

  1. 1

    How to get Last 10 records from OrmLite?

  2. 2

    How to skip last 2 records and get all other records with linq?

  3. 3

    How to get double records using LinQ?

  4. 4

    how to get latest distinct 10 records without null values using linq query

  5. 5

    How to get last 5 mins record from SQL database table?

  6. 6

    How to get last 5 mins record from SQL database table?

  7. 7

    how to get last 10 added records in sqlite table in iphone

  8. 8

    How to get last inserted records

  9. 9

    Retrieving 10 records at a time only using LINQ

  10. 10

    How can I iterate over the last 5 mins of my log file using bash

  11. 11

    How to restrict a user from submitting a form more than once in 10 mins using php

  12. 12

    How to get the last N records in mongodb?

  13. 13

    How to get first and last records between groups?

  14. 14

    How to get first and last records between groups?

  15. 15

    How to get last records with conditions from SQLite?

  16. 16

    Spring Data JPA Java - get Last 10 records from query

  17. 17

    Spring Data JPA Java - get Last 10 records from query

  18. 18

    How to make a query for showing records where time is not more then 30 mins

  19. 19

    How to get user records who don't visited in last two months using mysql

  20. 20

    how to get the last insert ID in linq

  21. 21

    how to get the last insert ID in linq

  22. 22

    Calculate mins in Linq

  23. 23

    Using output keyword to get last inserted records in SQL server?

  24. 24

    Netezza get records last updated in last 5 minutes using a last modified time stamp column in the table?

  25. 25

    Update records using LINQ

  26. 26

    Check was 10 mins elapsed

  27. 27

    Get records from table and related related table using Linq to entity

  28. 28

    using linq to entity to get records based on related entity

  29. 29

    Using Linq to get records that have specific foreign key

HotTag

Archive