FetchProjection and using DISTINCT

Posts   
 
    
Amith
User
Posts: 23
Joined: 21-Aug-2008
# Posted on: 18-May-2010 19:18:38   

Hi,

Is there any way to use DISTINCT in the sql statement generated using FetchProjection method instead of filtering the results after retrieving from database. I am using version 2.0

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 18-May-2010 20:52:42   

One of the parameters on the FetchProject method with be an "AllowDuplicates", which will emit a DISTINCT into the query when possible, if set to false.

Matt

Amith
User
Posts: 23
Joined: 21-Aug-2008
# Posted on: 18-May-2010 21:53:48   

MTrinder wrote:

One of the parameters on the FetchProject method with be an "AllowDuplicates", which will emit a DISTINCT into the query when possible, if set to false.

Matt

Thanks for the reply.

I tested by setting this parameter to false and "AllowDuplicates" parameter is not adding DISTINCT to the SQL statement instead of that this is filtering the results after fetching. This is creating a problem for me in paging. So I am looking for if there's any option to add DISTINCT to the SQL statement

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 18-May-2010 22:09:48   

There are various reasons why DISTINCT cannot sometime be emitted into the SQL - are you querying any text/memo/blob fields etc...?

Matt

Amith
User
Posts: 23
Joined: 21-Aug-2008
# Posted on: 19-May-2010 21:31:39   

MTrinder wrote:

There are various reasons why DISTINCT cannot sometime be emitted into the SQL - are you querying any text/memo/blob fields etc...?

Matt

No. It's sql statement to read from a View. The view is a UNION of 3 sql statements. Is it because of that?

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 20-May-2010 04:49:51   

Please show us how your projectors look like, and the snippet to fetch. The framework can't emit TOP if you have joins in the query, which means duplicates can occur, so it has to filter on the client, as it can't emit DISTINCT. This shouldn't lead to timeouts in all cases, as it simply reads till it has read the # of items to read.

David Elizondo | LLBLGen Support Team