[SOLVED] Typed List Question

Posts   
 
    
BSAPD avatar
BSAPD
User
Posts: 42
Joined: 02-Jul-2004
# Posted on: 19-Jul-2004 23:42:19   

I have a typed list that joins two entities (1:m) and it works fine if I only use the Fill overload with no parameters. When I use a Fill with max records and sort it returns a duplicate of every record (X2).

I don't know what I am doing wrong, but all I really want to do is set the sort and not use a max number of records.

Code: Dim sort As New SortExpression(SortClauseFactory.Create(ListFieldIndex.Name, SortOperator.Ascending))

Dim oLists As New ListWithListTypeTypedList oLists.Fill(100, sort) DataGrid1.DataSource = oLists

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 20-Jul-2004 12:14:06   

you can specify 0 for the maximum which returns all rows. When you use the overload for supplying a sort, please use the overload which accepts a boolean for allowDuplicates. Pass a 'false' for that parameter.

Frans Bouma | Lead developer LLBLGen Pro
BSAPD avatar
BSAPD
User
Posts: 42
Joined: 02-Jul-2004
# Posted on: 20-Jul-2004 17:07:24   

OK, I just tried that and it still has duplicates. There are only two records in my test table.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 20-Jul-2004 17:16:12   

It uses DISTINCT to filter out duplicates. If your table contains a text/ntext/image field (CLOB/BLOB on oracle) you will not be able to use DISTINCT as it is not allowed by sqlserver nor oracle to use distinct with these types.

If you don't have these fields, what is your template's version you're using?

Btw, just calling 'Fill()' will pass 'true' for allowDuplicates.

Frans Bouma | Lead developer LLBLGen Pro
BSAPD avatar
BSAPD
User
Posts: 42
Joined: 02-Jul-2004
# Posted on: 20-Jul-2004 17:56:56   

Here is the DDL for the table:

CREATE TABLE [dbo].[LIST_TBL] ( [PK_LIST_ID] [int] IDENTITY (1, 1) NOT NULL , [FK_SOURCE_TYPE_ID] [int] NOT NULL , [LIST_NAME] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL , [CONNECTION_INFO] [varchar] (200) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [SOURCE_TABLE] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [KEY_COLUMN_MAP] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [NAME_PREFIX_MAP] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [NAME_FIRST_MAP] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL , [NAME_LAST_MAP] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL , [NAME_SUFFIX_MAP] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [NAME_TITLE_MAP] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [DOB_MAP] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [AGE_MAP] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [ADDRESS1_MAP] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [ADDRESS2_MAP] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [ADDRESS_CITY_MAP] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [ADDRESS_STATE_MAP] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [ADDRESS_ZIP_MAP] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [ADDRESS_LAT_MAP] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [ADDRESS_LON_MAP] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [PHONE_MAIN_MAP] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [PHONE_FAX_MAP] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [EMAIL_MAP] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [IS_MAIL_CAPABLE] [bit] NULL , [IS_EMAIL_CAPABLE] [bit] NULL , [IS_FAX_CAPABLE] [bit] NULL , [IS_PHONE_CAPABLE] [bit] NULL ) ON [PRIMARY] GO

ALTER TABLE [dbo].[LIST_TBL] WITH NOCHECK ADD CONSTRAINT [PK_LIST_TBL] PRIMARY KEY CLUSTERED ( [PK_LIST_ID] ) ON [PRIMARY] GO

ALTER TABLE [dbo].[LIST_TBL] ADD CONSTRAINT [FK_LIST_TBL_LIST_SOURCE_TBL] FOREIGN KEY ( [FK_SOURCE_TYPE_ID] ) REFERENCES [dbo].[LIST_SOURCE_TYPE_TBL] ( [PK_LIST_SOURCE_TYPE_ID] ) GO

I am using the following template configuration:

Name: General config Vs.Net 2003 Version: 1.0.2004.1.053104

Name: VB.NET template set for SqlServer (1.0.2004.1) Version: 1.0.2003.3.070704 Vendor: Solutions Design Target language: VB.NET

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 20-Jul-2004 18:13:42   

And these fields are in your typed list, or are there more fields from other entities? If not, have you checked if there are no duplicate rows in your database?

Frans Bouma | Lead developer LLBLGen Pro
BSAPD avatar
BSAPD
User
Posts: 42
Joined: 02-Jul-2004
# Posted on: 20-Jul-2004 19:15:52   

Oh, Sorry. The fields in my typed list are PK_LIST_ID, FK_SOURCE_TYPE_ID, LIST_NAME, IS_MAIL_CAPABLE, IS_EMAIL_CAPABLE, IS_FAX_CAPABLE, IS_PHONE_CAPABLE from the table I sent you and it also contains LIST_SOURCE_TYPE from a lookup table. There are no duplicates in either table.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 20-Jul-2004 19:19:25   

BSAPD wrote:

Oh, Sorry. The fields in my typed list are PK_LIST_ID, FK_SOURCE_TYPE_ID, LIST_NAME, IS_MAIL_CAPABLE, IS_EMAIL_CAPABLE, IS_FAX_CAPABLE, IS_PHONE_CAPABLE from the table I sent you and it also contains LIST_SOURCE_TYPE from a lookup table. There are no duplicates in either table.

And List_SOURCE_TYPE is a normal varchar field? (I guess so).

And you are positive that if you call Fill() normally it doesn't show the duplicates?

Frans Bouma | Lead developer LLBLGen Pro
BSAPD avatar
BSAPD
User
Posts: 42
Joined: 02-Jul-2004
# Posted on: 20-Jul-2004 19:23:02   

OK, I am a complete bozo flushed , I just noticed that I was still calling Fill() after calling Fill(0, sort, False). I am terribly sorry for waisting your time. You fix three or four posts ago fixed my issue.

Thanks! & Sorry!

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 20-Jul-2004 20:09:21   

BSAPD wrote:

OK, I am a complete bozo flushed , I just noticed that I was still calling Fill() after calling Fill(0, sort, False). I am terribly sorry for waisting your time. You fix three or four posts ago fixed my issue.

Thanks! & Sorry!

heh simple_smile No problem simple_smile I already wondered why it didn't work... simple_smile

Frans Bouma | Lead developer LLBLGen Pro