AnantLabs / codesmith

Automatically exported from code.google.com/p/codesmith
1 stars 0 forks source link

CSLA - Update EditableRootList's DataPortal_Update Method #537

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
http://forums.lhotka.net/forums/t/9854.aspx

Original issue reported on code.google.com by bniemyj...@codesmithtools.com on 19 Dec 2010 at 12:42

GoogleCodeExporter commented 9 years ago

Original comment by bniemyjski on 19 Dec 2010 at 12:47

GoogleCodeExporter commented 9 years ago
Here is my changes to ObjectFactoryList.DataAccess.ParameterizedSQL.cst
to add update to EditableRootList.

<% if(!IsReadOnlyBusinessObject) { %>
#region Update
/// <summary>
        /// Update <%= Entity.ClassName %>List.
        /// </summary>
        /// <param name="oldList"> <%= Entity.ClassName %>ListFactory.</param>
        /// <returns name newList> <%= Entity.ClassName %>ListFactory</returns>
        // CMS Create Script CSHARP\DataAccessLayer\ObjectFactoryList.DataAccess.ParameterizedSQL.cst
        public <%= Entity.ClassName %>List Update(<%= Entity.ClassName %>List oldList)
        {
                        <%= Entity.ClassName %>Factory listFactory = (<%= Entity.ClassName %>Factory)Activator.CreateInstance(typeof(<%= Entity.ClassName %>Factory), true);
            Csla.Core.MobileList<<%= Entity.ClassName %>> deleteList = GetDeletedList<<%= Entity.ClassName %>>(oldList);
                        if((deleteList != null) && (deleteList.Count > 0))
            {
                foreach(<%= Entity.ClassName %> deletedItem in deleteList)
                {
                    listFactory.Update(deletedItem);
                }
                deleteList.Clear();
            }
                        foreach (<%= Entity.ClassName %> item in oldList)
            {
                if (item.IsDirty)
                {
                    <%= Entity.ClassName %> newItem = listFactory.Update(item);
                                    }
                            }
                       return oldList;
                    }
#endregion

Original comment by cmsmi...@msn.com on 28 Mar 2011 at 1:58

GoogleCodeExporter commented 9 years ago

Original comment by bniemyjski on 28 Mar 2011 at 6:13