EditableRootListBase - The Correct WayEditableRootListBase - 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;
[Serializable()]
public class Customers : EditableRootListBase<Customer>
{
#region Business Methods
protected override object AddNewCore()
{
Customer item = Customer.NewCustomer;
Add(item);
return item;
}
#endregion
#region Factory Methods
public static Customers GetList()
{
return DataPortal.Fetch<Customers>();
}
private Customers()
{
this.AllowEdit = true;
this.AllowNew = true;
this.AllowRemove = true;
}
#endregion
#region Data Access
private void DataPortal_Fetch()
{
using (var mgr = ContextManager<Northwind.DALLinq.NorthwindDataContext>
.GetManager(Northwind.DALLinq.Database.Northwind, false))
{
RaiseListChangedEvents = false;
this.AddRange(
from row in mgr.DataContext.Customers
select Customer.GetCustomer(row.CustomerID)
);
RaiseListChangedEvents = true;
}//using
}
#endregion
}
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 ?
Thanks.
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