Runselect passing a paging object

Feb 2, 2010 at 1:07 PM

When attempting to use the Runselect method passing a paging object I am receiving an "Object reference not set to an instance of an object" error.  From what I can tell when building the order by clause in the "GetPagedSQL" the code is unable to find the field it needs in order to build the clause.

Below is an example line of code that is causing the issue when attempting to order by the "Name" field:

case "name": orderByClause += "[" + (from x in fieldList where x.Alias == fieldItem.Field.ToString() select x).FirstOrDefault().Table + "].[Name]" + (fieldItem.Ascending ? "" : " DESC"); break;


When I modify the code replacing "x.Alias == fieldItem.Field.ToString()" with "x.Alias.ToLower() == fieldItem.Field.ToString().ToLower()" the code no longer errors out, is there something I am doing wrong here?  I have included the schema for the actual table if that will help.

CREATE TABLE [dbo].[Events] (
[Address] [VarChar] (200) NULL ,
[Area] [Int] NULL ,
[City] [VarChar] (75) NULL ,
[ContactName] [VarChar] (50) NULL ,
[CreateDate] [DateTime] NULL  CONSTRAINT [DF__EVENTS_CREATEDATE] DEFAULT (getdate()),
[Description] [Text] NULL ,
[Email] [VarChar] (50) NULL ,
[EndDate] [DateTime] NOT NULL ,
[Event_Image] [VarChar] (250) NULL ,
[Fax] [VarChar] (50) NULL ,
[ID] [Int] IDENTITY (1, 1) NOT NULL ,
[IdName] [VarChar] (75) NOT NULL  CONSTRAINT [DF__EVENTS_IDNAME] DEFAULT ('event'),
[isFront] [Bit] NULL  CONSTRAINT [DF__EVENTS_ISFRONT] DEFAULT (0),
[isVisible] [Bit] NOT NULL  CONSTRAINT [DF__EVENTS_ISVISIBLE] DEFAULT (1),
[Name] [VarChar] (200) NOT NULL ,
[Notes] [Text] NULL ,
[Phone] [VarChar] (50) NULL ,
[Price] [VarChar] (60) NULL ,
[shortdescription] [VarChar] (250) NULL ,
[StartDate] [DateTime] NOT NULL ,
[State] [VarChar] (50) NULL  CONSTRAINT [DF__EVENTS_STATE] DEFAULT ('SC'),
[StatusId] [Int] NOT NULL  CONSTRAINT [DF__EVENTS_STATUSID] DEFAULT (1),
[TollFree] [VarChar] (50) NULL ,
[Website] [VarChar] (50) NULL ,
[Zip] [VarChar] (50) NULL
)

Coordinator
Feb 3, 2010 at 4:05 PM

I am unable to reproduce. Can you please paste the calling code.

Feb 3, 2010 at 10:45 PM

Thanks for the reply, here is the code segment that is giving me issues:

EventsPaging paging = new EventsPaging(1, 5);

paging.OrderByList.Add(new EventsPagingFieldItem(Georgetown.County.Business.Objects.Events.FieldNameConstants.Name, true));

Response.Write(EventsCollection.RunSelect(x => x.StartDate > DateTime.Now, paging).Count);

All I am trying to do is to display on screen the number of returned records which in the case should be 5.  If you need any further information feel free to let me know.

Coordinator
Feb 4, 2010 at 2:29 AM

I have fixed the issue.  We will be putting out a new version this weekend. If you need to fix feel free to go get it from the svn tree. You will notice a checkin with a comment to this issue. It is as you said. We need to put a tolower() on each side. Thanks for posting the issue.

https://nhydrate.svn.codeplex.com/svn  

Feb 4, 2010 at 1:47 PM

Again thanks for your help.

 

Coordinator
Feb 8, 2010 at 1:21 AM

A new version has been posted. Please download it and regenerate your code.