EditableRootListBase example

EditableRootListBase example

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


RockfordLhotka posted on Monday, November 06, 2006

Since I forgot to update the templates for 2.1 (and thus didn't add a template for ERLB), here's a quick template of a list that contains objects of type "Root". "Root" objects are normal editable root objects.

<Serializable()> _
Public Class RootList
  Inherits EditableRootListBase(Of Root)

#Region " Business Methods "

  Protected Overrides Function AddNewCore() As Object

    Dim item As Root = Root.NewRoot
    Add(item)
    Debug.WriteLine("Added " & Me.Count - 1)
    Return item

  End Function

#End Region

#Region " Factory Methods "

  Public Shared Function GetList() As RootList
    Return DataPortal.Fetch(Of RootList)(New Criteria)
  End Function

  Private Sub New()

    Me.AllowEdit = True
    Me.AllowNew = True
    Me.AllowRemove = True

  End Sub

#End Region

#Region " Data Access "

  <Serializable()> _
  Private Class Criteria

  End Class

  Private Overloads Sub DataPortal_Fetch(ByVal criteria As Criteria)

    ' load list here

  End Sub

#End Region

End Class

Smirk replied on Tuesday, November 07, 2006

Grins #ly

---------------------------------------------------------------------------------------

using System;

using System.Diagnostics;

using Csla;

using Csla.Core;

namespace SomeNamespace

{

   [Serializable()]

   public class RootList: EditableRootListBase<Root>

   {

      #region Business Methods

      protected override object AddNewCore()

      {

      Root item = Root.NewRoot;

      Add(item);

      Debug.WriteLine("Added " + this.Count -1);

      return item;

      }

      #endregion

      #region Factory Methods

      public static RootList GetList()

      {

      return DataPortal.Fetch<RootList>(new Criteria());

      }

      private RootList()

      {

         this.AllowEdit = true;

         this.AllowNew = true;

         this.AllowRemove = true;

      }

   #endregion

   #region Data Access

   [Serializable()]

   private class Criteria

   {

   }

   protected override void DataPortal_Fetch(Criteria criteria)

   {

      // Load list here.

   }

   #endregion

   }

}

----------------------------------------------------------------------------------------------------

I think I got it all...

Mark Haley

 

tiago replied on Monday, December 04, 2006

I guess the template name should be RootList.cs (and not EditableRootListBase.cs). Correct?

RockfordLhotka replied on Monday, December 04, 2006

fwiw, I'm using the term "DynamicRootList" in the 2.1 ebook (which is nearing completion finally).
 
Rocky
 


From: tiago [mailto:cslanet@lhotka.net]
Sent: Monday, December 04, 2006 7:07 AM
To: rocky@lhotka.net
Subject: Re: [CSLA .NET] EditableRootListBase example

I guess the template name should be RootList.cs (and not EditableRootListBase.cs). Correct?


rashid replied on Wednesday, July 09, 2008

Hi,

 This is Editable Root List base, the methods for update, delete and Add new is not there is the example. Can you please elaborate your example for more details.

 

Thanks & RegardsSmile [:)]

Rashid

 

RockfordLhotka replied on Thursday, July 10, 2008

For full details see the CSLA .NET Version 2.1 Handbook ebook.

An ERLB collection contains editable root objects, so each "child" object is responsible for its own insert/update/delete.

Copyright (c) Marimer LLC