You mention "notification" which is key, I think, in finding a solution.

Say the data access class has an event:

class EmployeeDAL
{
  event void DataLoadFailed(object sender, DataLoadFailedEventArgs e);

  List<Employee> GetList()
  {
    // data access returns data reader
    while (reader.Read())
    {
      try
      {
        localList.Add(new Employee(reader[0], reader[1]);
      }
      catch (SqlException)
      {
        DataLoadFailed(this, new DataLoadFailedEventArgs(reader[0]);
      }
    }

    return localList;
   }
}

where reader[0] is a primary key field that can never be at fault, to at
least identify the faulty record.

The client would handle DataLoadFailed. It might be best that in the catch
of GetList(), to spin off a thread to raise DataLoadFailed, so that the list
can continue without being blocked by the client.

Just my thoughts,
Ron

-----Original Message-----
From: Discussion of advanced .NET topics.
[mailto:[EMAIL PROTECTED] On Behalf Of Shane Courtrille
Sent: Friday, May 11, 2007 4:33 PM
To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM
Subject: [ADVANCED-DOTNET] Loading Entities & Reporting Problems

I've been working with loading entities from databases lately.  One of the
problems you sometimes run into is an entry that can't be loaded properly.
For some reason or other some of the data associated with it is bad.  Now at
this point you could throw an exception but you might not want to interrupt
the loading.  Instead you may want to load the item up and somehow pass up a
notification that there was a problem.

I've been thinking of notification sets as used in business rule systems and
if that was something that could be used.  So my question to everyone is how
have they dealt with this problem?  Does anyone have a cool/interesting
system that deals with loading entities which deals with problems while
still allowing the loading of the entity?

Thanks,

Shane

===================================
This list is hosted by DevelopMentorR  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

===================================
This list is hosted by DevelopMentorĀ®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to