This is a migrated thread and some comments may be shown as answers.

Question regarding .Take(NumItems)

9 Answers 60 Views
LINQ (LINQ specific questions)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Seabus
Top achievements
Rank 1
Seabus asked on 13 Sep 2011, 04:40 PM

Hi,

Simple question:

var query = (from Person p in Persons select p).Take(5).ToList();

Does OpenAccess turn this into a SELECT TOP 5 statement ??? :-)


MadSeb


9 Answers, 1 is accepted

Sort by
0
Thomas
Telerik team
answered on 14 Sep 2011, 09:08 AM
Hello Seabus,

Simple answer: Yes.

All the best,
Thomas
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's SQL Server Community Awards. We are competing in TWO categories and every vote counts! VOTE for Telerik NOW >>

0
Rui
Top achievements
Rank 1
answered on 09 Feb 2012, 12:26 PM
Hello, if I have something like this:

var c = from p in ctx.GetAll<Person >().Where(x => x.Name.Contains(e.Text)).Take(15)
                           select new
                                  {
                                      p.IdPerson,
                                      p.name
              };

var count = c.Count(); //<- this will not be 15, it will be the total where clause result count

What am I doing wrong?
0
Thomas
Telerik team
answered on 09 Feb 2012, 06:11 PM
Hello Rui,

I just double checked that this does not occur. Which database version and which OpenAccess version do you use? Do you use fetchplans or FetchStrategy ? Can you give us your .rlinq file?
Greetings,
Thomas
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Rui
Top achievements
Rank 1
answered on 09 Feb 2012, 10:18 PM
Hello,
telerik openaccess version: 2011.3.1129.2
DB Version: SQLServer 2008 R2

I just build the rlinq from the DB and the I just use something like:

 using (var ctx = new DbContext())
            {

var c = from p in ctx.GetAll<Person >().Where(x => x.Name.Contains(e.Text)).Take(15)
                           select new
                                  {
                                      p.IdPerson,
                                      p.name
              };

var count = c.Count();

}
0
Rui
Top achievements
Rank 1
answered on 09 Feb 2012, 10:19 PM
I'm using .NET 3.5, does it matter?
0
Rui
Top achievements
Rank 1
answered on 10 Feb 2012, 01:42 AM
Hello.
The database is taken from http://northwind.codeplex.com/
In attachement is a sample application (with rlinq file: http://www.wupload.com/file/2661526527/WebApplication1.7z

thank you
0
Thomas
Telerik team
answered on 10 Feb 2012, 01:03 PM
Hello Rui,

works like a charm on my side...

SELECT TOP(@__TAKE) a.[ContactName] AS COL1, a.[ID] AS COL2 FROM [Customer] a


Please double check your configuration, esp. that there is no reference to older OpenAccess versions.
I tested here with the newest upcoming build.

Greetings,
Thomas
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Rui
Top achievements
Rank 1
answered on 11 Feb 2012, 10:14 PM
I don't quite understand how you get that query...
What version are you using?
Since it's a Count() why in you query there is no TOP?

here is my result for count(): untitled.png

when I use tolist: tolist.png

0
Rui
Top achievements
Rank 1
answered on 11 Feb 2012, 10:42 PM
With the Latest internal build: 2011.3.1320.1 is working.
Tags
LINQ (LINQ specific questions)
Asked by
Seabus
Top achievements
Rank 1
Answers by
Thomas
Telerik team
Rui
Top achievements
Rank 1
Share this question
or