EditableRootListBase - The Correct Way

EditableRootListBase - The Correct Way

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

Pieter posted on Tuesday, June 16, 2009

Hi All,

Is this the correct way to implement an EditableRootListBase in version 3.6? :

using System;
using System.Linq;
using Csla;
using Csla.Data;

public class Customers : EditableRootListBase<Customer>
    #region  Business Methods
    protected override object AddNewCore()
        Customer item = Customer.NewCustomer;
        return item;

    #region  Factory Methods
    public static Customers GetList()
        return DataPortal.Fetch<Customers>();

    private Customers()
        this.AllowEdit = true;
        this.AllowNew = true;
        this.AllowRemove = true;


    #region  Data Access

    private void DataPortal_Fetch()

        using (var mgr = ContextManager<Northwind.DALLinq.NorthwindDataContext>
                   .GetManager(Northwind.DALLinq.Database.Northwind, false))
            RaiseListChangedEvents = false;

                from row in mgr.DataContext.Customers
                select Customer.GetCustomer(row.CustomerID)

            RaiseListChangedEvents = true;



rfcdejong replied on Tuesday, June 16, 2009

It looks fine to me, ignoring the data access part.
And assuming u ment to use the BusinessListBase<T, C> as base class.

Pieter replied on Wednesday, June 17, 2009

Can you please give an example of the correct data access part and what you mean by BusinessListBase<T, C> as base class ?


rfcdejong replied on Wednesday, June 17, 2009

Sorry for confusing you, u could use a EditableRootListBase as well (if u want to edit directly in the root).

I didn't look at your data access, it could be working.

Copyright (c) Marimer LLC