PDA

View Full Version : سوال: براي گرفتن ركورد هاي معين چه دستور Query بايد نوشت



ROSTAM2
سه شنبه 20 تیر 1391, 23:17 عصر
چه دستور Query قادر به فيلتر كردن اطلاعات است بطوريكه تعداد ركورد هاي اون محدود بشه به اون تعدادي كه ما مي خوايم ، مثلا 5 ركورد يا 10 ركورد و يا ...

salehbagheri
چهارشنبه 21 تیر 1391, 00:51 صبح
LINQ این کار رو برای شما ساده کرده!

از متد ()Take در انتهای درخواست خود استفاده کنید!

مثال مایکروسافت:


' Create an array of Integer values that represent grades.
Dim grades() As Integer = {59, 82, 70, 56, 92, 98, 85}
' Get the highest three grades by first sorting
' them in descending order and then taking the
' first three values.
Dim topThreeGrades As IEnumerable(Of Integer) = _
grades _
.OrderByDescending(Function(grade) grade) _
.Take(3)

' Display the results.
Dim output As New System.Text.StringBuilder("The top three grades are:" & vbCrLf)
For Each grade As Integer In topThreeGrades
output.AppendLine(grade)
Next
MsgBox(output.ToString())
' This code produces the following output:
'
' The top three grades are:
' 98
' 92
' 85

فرید نجفلو
چهارشنبه 21 تیر 1391, 13:34 عصر
سلام
اگه با دستورات SQL کار می کنید:
SELECT TOP 10 * FROM Table1