ChildCollections fed by LLBLGen EntityClass

ChildCollections fed by LLBLGen EntityClass

Old forum URL: forums.lhotka.net/forums/t/2253.aspx


swegele posted on Wednesday, January 31, 2007

Hey all,

I am designing a BL with 2.1.2 around the latest LLBLGen DAL.  Man it looks like this is going to be a match made in heaven!  Seems to be fitting together nicely minus one thing that is stumping me.

The problem I am having is deciding how to architect the ChildCollections in the BL with CSLA.  The EntityClass from LLBLGen actually holds all the data that was fetched and relations too.  EX:

Class EmployeeEditableRoot
  Inherits BusinessBase

    Private mDALEmployee as EntityClasses.EmployeeEntity

    Public ReadOnly Property ID As String
      Get
         Return mDALEmployee.ID
      End Get
    End Property

  So what makes sense here as far as wrapping the DAL entities ??

1.  Have an editable root with a private LLBLEntityClass that feeds all properties and child collections.  Child collections in BL would be NotUndoable and NonSerializable and just temporary wrappers for the child data that is in the DALEntityClass.  The BL child collections would hydrate upon deserialization pulling the related collections out of the DALEntityClass and exposing them in the proper BLChild classes/collections.  But when EditableRoot BL object serializes it in effect would drop all it's child collections and rehydrate them on the other side of the portal because the DALEntityClass came with.  Like so:

<NotUndoable(), NonSerializable()> Private mAddresses as EmployeeAddresses

Public ReadOnly Property AddressList as EmployeeAddresses
  Get
    If mAddresses Is Nothing Then
      'dynamically build Employee Addresses first fetch from DAL Object 
      For i = 0 to mDALEmployee.EmpAddress.Count -1
etc.
 

2.  OR...Don't use the DALEntityClass to hold all the child data...instead design one to one where the BLChildCollections actually persist holding the BLChildren which have a private member of that related DALEntity.  I could still use the fetch DALEntityClass to fetch all data at once (using prefetch paths) but then strip it out into the corresponding BLCollections and then clear the DALEntityClass child collections so they don't take up a ton of space during de/serialization.  The child BL Collections would get populated on the initial fetch or on demand.

Private mAddresses as EmployeeAddresses

Public ReadOnly Property EmpAddressList as EmployeeAddressList
  Get
    If mAddresses Is Nothing Then
     
'get Employee Addresses first fetch from DB through portal
      mAddresses = EmployeeAddressList.GetList(mDALEmployee.ID)
etc.

I was leaning towards 1 but I am not that far into it yet and I could go either way...wondering if 2 makes more sense in the end especially since LLBLGen doesn't keep track of IsDeleted like CSLA does.

Give me your thoughts

Sean Wegele

Copyright (c) Marimer LLC