Select Distinct with DataAccessAdapter

Posts   
 
    
Fawlty
User
Posts: 1
Joined: 23-Mar-2007
# Posted on: 23-Mar-2007 21:58:06   

I have a question that relates to http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=1772&HighLight=1 with the exception that my query is much simpler. There are no joins or filters needed with the exception of distinct.

I am creating an entity whose sole purpose is to create a distinct list of categories from a column and populate a dropdown. When creating a relation between entities I can get the query to select a distinct, but the relation can't be created on this category column. I have to add another key, which then causes the distinct to be applied to both columns and no longer returns a distinct list of categories.

The ideal query that I simply want to run is

select distinct category from testing

but SQL Profiler shows that the distinct is not being applied.

I am calling:

EntityCollection<TestingCategoriesEntity> tce = new EntityCollection<TestingCategoriesEntity>(new TestingCategoriesEntityFactory());
DataAccessAdapter ad = new DataAccessAdapter();
ad.FetchEntityCollection(tce, null);

My entity contains category and thats it. How do I add the distinct?

Currently we are running LLBL Pro 2.0.0.0 Final with SQL Server 2005.

Many Thanks,

Jeff

JimHugh
User
Posts: 191
Joined: 16-Nov-2005
# Posted on: 23-Mar-2007 23:07:43   

In this case, you should probably use a TypedList instead of an entitycollection.

Then use set AllowDuplicates paramter in adapter.FetchTypedList to true.