कभी-कभी, टीएसक्यूएल जाने का रास्ता है। मैं ExecuteQuery<T>
. का उपयोग करूंगा यहाँ:
var data = db.ExecuteQuery<SomeObjectType>(@"
SELECT * FROM
(SELECT *, ROW_NUMBER() OVER (ORDER BY id) AS [__row]
FROM [YourTable]) x WHERE (x.__row % 25) = 1");
आप n
. की अदला-बदली भी कर सकते हैं :
var data = db.ExecuteQuery<SomeObjectType>(@"
DECLARE @n int = 2
SELECT * FROM
(SELECT *, ROW_NUMBER() OVER (ORDER BY id) AS [__row]
FROM [YourTable]) x WHERE (x.__row % @n) = 1", n);