Deleting a row from TypedList

Posts   
 
    
Jamanga
User
Posts: 93
Joined: 21-Jul-2006
# Posted on: 07-Apr-2009 02:59:12   

Hi,

Before updating to the latest runtime last week, the following code used to work - the main thing that used to happen is that when .Delete() was called on an item within a TypedList, it used to be removed from the TypedList container - but now this doesn't seem happen?

Both were under 2.6, I'm not sure of the previous runtime, but it would have been from around September last year.

Current Version: LLBLGen 2.6 Designer (Oct 6, 2008 ) Runtime versions: SD.LLBLGen.Pro.ORMSupportClasses.NET20.dll : 2.6.9.313 SD.LLBLGen.Pro.DQE.SybaseAse.NET20.dll : 2.6.8.819

Basically I iterate through the returned typedlist and creating a counter list, then removing any "duplicates" using the .Delete().

I then go through the smaller list again, updating the writable LouthDayCount property, which gets displayed with the other info. in the grid.

Code below:

ScheduleResourceTypedList myScheduleResourcesList = dsSchedule.TypedList as ScheduleResourceTypedList;

// list of Louth keys + instance counter
Dictionary<string, int> myLouthKeyList = new Dictionary<string, int>();
for (int iIdx = myScheduleResourcesList.Count-1; iIdx >= 0; iIdx--) {
    ScheduleResourceRow thisRow = myScheduleResourcesList[iIdx] as ScheduleResourceRow;
    string sThisLouthId = String.Format(SummaryKeyFormat, thisRow.ScheduleDate, thisRow.LouthId);
    if (myLouthKeyList.ContainsKey(sThisLouthId)) {
        myLouthKeyList[sThisLouthId] += 1;
        thisRow.Delete(); // RELEVANT LINE!
    } else {
        myLouthKeyList.Add(sThisLouthId, 1);
    }
}

// iterate through the summary rows, updating the Louth count value
foreach (ScheduleResourceRow thisRow in myScheduleResourcesList) {
    thisRow.LouthDayCount = myLouthKeyList[String.Format(SummaryKeyFormat, thisRow.ScheduleDate, thisRow.LouthId)];
}

Any ideas?

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 07-Apr-2009 03:23:38   
  • Please update to the latest runtime library version.
  • Are you sure the debugger is entering into this if?
if (myLouthKeyList.ContainsKey(sThisLouthId)) {
  • I assume the problem is that the typedList row isn't removed from the typelist, right?
David Elizondo | LLBLGen Support Team
Jamanga
User
Posts: 93
Joined: 21-Jul-2006
# Posted on: 07-Apr-2009 04:21:10   

Hi - thanks for the response.

daelmo wrote:

  • Please update to the latest runtime library version.

Willdo, it takes me a little time to do this because I have to use an a slightly altered ormsupportclasses due to our use of Sybase ASE.. disappointed

I have a meeting now, hopefully will be out of it in 2 hours + do this + let you know.

daelmo wrote:

  • Are you sure the debugger is entering into this if?
if (myLouthKeyList.ContainsKey(sThisLouthId)) {

Yep, it is sure is simple_smile

daelmo wrote:

  • I assume the problem is that the typedList row isn't removed from the typelist, right?

Exactly! I should have mentioned the error before sorry, a DeletedRowInaccessible Exception gets raised during...

foreach (ScheduleResourceRow thisRow in myScheduleResourcesList) {
    thisRow.LouthDayCount = myLouthCountList[String.Format(SummaryKeyFormat, thisRow.ScheduleDate, thisRow.LouthId)];
}

... when I try to read the thisRow.ScheduleDate property, because this particular row was "deleted" (...but its still in my typed list collection... which is my issue)

Jamanga
User
Posts: 93
Joined: 21-Jul-2006
# Posted on: 07-Apr-2009 04:42:19   

Wow a quick meeting, may the rest of my day be this lucky simple_smile

I've updated to latest the ORMSupportTools assembly + recompiled, now at version 2.6.9.327, and the issue is still the same.

btw. I checked on my Production WebServer i.e. where it seems to work ok and the runtime assembly was 2.6.8.819 if this helps.

Walaa avatar
Walaa
Support Team
Posts: 14946
Joined: 21-Aug-2005
# Posted on: 07-Apr-2009 10:51:10   

Please delete the row from the DefaultView of the typedList using its index;

mytypedList.DefaultView.Delete(rowIndex);

And to test it you can check on the Count of the DefaultView before and after the deletion.

Jamanga
User
Posts: 93
Joined: 21-Jul-2006
# Posted on: 08-Apr-2009 00:05:07   

Hi Walaa

Thanks, but that made no difference

i.e. i changed

thisRow.Delete();

to

myScheduleResourcesList.DefaultView.Delete(iIdx);

..and the myScheduleResourcesList.Count didn't decrease?

Jamanga
User
Posts: 93
Joined: 21-Jul-2006
# Posted on: 08-Apr-2009 03:52:49   

Ok this one seems to work

myScheduleResourcesList.Rows.Remove(thisRow);