AnantLabs / codesmith

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

NameValueList.cst is overwriting my customCode partial class, which it shouldn't #363

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Use the NameValueList.cst in 1631 CSLA template to re-produce

Was like this before:

//------------------------------------------------------------------------------
// <autogenerated>
//     This code was generated using CodeSmith: v5.2.2, CSLA Templates:
v2.0.1.1631, CSLA Framework: v3.8.2.
//       Changes to this template will not be lost.
//
//     Template: NameValueList.cst
//     Template website: http://code.google.com/p/codesmith/
// </autogenerated>
//------------------------------------------------------------------------------
#region Using declarations

using System;
using System.Data;
using System.Data.SqlClient;

using Csla;
using Csla.Data;

#endregion

namespace RecoveryPlanner.Business
{
    public partial class ProjectNameValueList
    {
        #region "Preserved Code"

        #region Custom Data Access

        public static ProjectNameValueList
GetAllProjectsByUsernameAndEmployeeTypeId(string username, int employeeTypeId)
        {
            //removed in case the list needs to be refreshed, e.g. if the
employee is moved between EmployeeTypeId's:
            //if (_list == null) 
            _list = DataPortal.Fetch<ProjectNameValueList>(new
ProjectCriteria(username, employeeTypeId));

            return _list;
        }

        //Má ekki sækja eftir engum params ... eingöngu nota aðgangstýrð föll!
        /*public static ProjectNameValueList GetAll()
        {
            if(_list == null)
                _list = DataPortal.Fetch< ProjectNameValueList >();

            return _list;
        } */

        private void DataPortal_Fetch(ProjectCriteria criteria)
        {
            RaiseListChangedEvents = false;
            IsReadOnly = false;

            //var criteria = new ProjectCriteria();
            using (SqlConnection connection = new
SqlConnection(ADOHelper.ConnectionString))
            {
                connection.Open();
                using (SqlCommand command = new
SqlCommand("[dbo].[rp_Project_Select]", connection))
                {
                    command.CommandType = CommandType.StoredProcedure;

command.Parameters.AddRange(ADOHelper.SqlParameters(criteria.StateBag));

command.Parameters.AddWithValue("@InvolvedPartyIdHasValue",
criteria.InvolvedPartyIdHasValue);
                    command.Parameters.AddWithValue("@ProjectNameHasValue",
criteria.ProjectNameHasValue);
                    command.Parameters.AddWithValue("@DateKickOffHasValue",
criteria.DateKickOffHasValue);

command.Parameters.AddWithValue("@DateRegisteredHasValue",
criteria.DateRegisteredHasValue);

command.Parameters.AddWithValue("@DateInactiveTimestampHasValue",
criteria.DateInactiveTimestampHasValue);

command.Parameters.AddWithValue("@ReasonForRecoveryHasValue",
criteria.ReasonForRecoveryHasValue);

command.Parameters.AddWithValue("@IsCompanyInLegalDebtCollectionHasValue",
criteria.IsCompanyInLegalDebtCollectionHasValue);

command.Parameters.AddWithValue("@StatusInRecoveryHasValue",
criteria.StatusInRecoveryHasValue);

command.Parameters.AddWithValue("@ExpectedOutcomeHasValue",
criteria.ExpectedOutcomeHasValue);

command.Parameters.AddWithValue("@ProjectDescriptionHasValue",
criteria.ProjectDescriptionHasValue);

                    //These parameters specify which project the user is
able to see:
                    /*command.Parameters.AddWithValue("@Username",
criteria.Username);
                    command.Parameters.AddWithValue("@EmployeeTypeId",
criteria.EmployeeTypeId);*/

                    using (var reader = new
SafeDataReader(command.ExecuteReader()))
                    {
                        if (reader.Read())
                        {
                            do
                            {
                                this.Add(new
NameValuePair(reader.GetInt32("ProjectID"), reader.GetString("ProjectName")));
                            } while (reader.Read());
                        }
                        //Ekki kasta neinu, grunnurinn gæti einfaldlega
verið tómur.-
                        //else
                        //throw new Exception(string.Format("The record was
not found in 'Project' using the following criteria: {0}.", criteria));
                    }
                }
            }

            //IsReadOnly = true;
            RaiseListChangedEvents = true;
        }

        #endregion

        #endregion
    }
}

THEN I use the CodeGen against the template, and it OVERWRITES my
custom-code file like this:

//------------------------------------------------------------------------------
// <autogenerated>
//     This code was generated using CodeSmith: v5.2.2, CSLA Templates:
v2.0.1.1631, CSLA Framework: v3.8.2.
//       Changes to this template will not be lost.
//
//     Template: NameValueList.cst
//     Template website: http://code.google.com/p/codesmith/
// </autogenerated>
//------------------------------------------------------------------------------
#region Using declarations

using System;
using System.Data;
using System.Data.SqlClient;

using Csla;
using Csla.Data;

#endregion

namespace RecoveryPlanner.Business
{
    public partial class ProjectNameValueList
    {
        #region "Preserved Code"

        #region Custom Data Access

        private void DataPortal_Fetch()
        {
            RaiseListChangedEvents = false;
            IsReadOnly = false;

            var criteria = new ProjectCriteria();
            using (SqlConnection connection = new
SqlConnection(ADOHelper.ConnectionString))
            {
                connection.Open();
                using (SqlCommand command = new
SqlCommand("[dbo].[rp_Project_Select]", connection))
                {
                    command.CommandType = CommandType.StoredProcedure;

command.Parameters.AddRange(ADOHelper.SqlParameters(criteria.StateBag));

command.Parameters.AddWithValue("@InvolvedPartyIdHasValue",
criteria.InvolvedPartyIdHasValue);
                    command.Parameters.AddWithValue("@ProjectNameHasValue",
criteria.ProjectNameHasValue);
                    command.Parameters.AddWithValue("@DateKickOffHasValue",
criteria.DateKickOffHasValue);
                    command.Parameters.AddWithValue("@DateRegisteredHasValue",
criteria.DateRegisteredHasValue);
                    command.Parameters.AddWithValue("@DateInactiveTimestampHasValue",
criteria.DateInactiveTimestampHasValue);
                    command.Parameters.AddWithValue("@ReasonForRecoveryHasValue",
criteria.ReasonForRecoveryHasValue);

command.Parameters.AddWithValue("@IsCompanyInLegalDebtCollectionHasValue",
criteria.IsCompanyInLegalDebtCollectionHasValue);
                    command.Parameters.AddWithValue("@StatusInRecoveryHasValue",
criteria.StatusInRecoveryHasValue);
                    command.Parameters.AddWithValue("@ExpectedOutcomeHasValue",
criteria.ExpectedOutcomeHasValue);
                    command.Parameters.AddWithValue("@ProjectDescriptionHasValue",
criteria.ProjectDescriptionHasValue);
                    using(var reader = new
SafeDataReader(command.ExecuteReader()))
                    {
                        if(reader.Read())
                        {
                            do
                            {
                                // TODO: You will need to update the
GetInt32 and GetString values.
                                this.Add(new
NameValuePair(reader.GetInt32("ProjectID"), reader.GetString("ProjectID")));
                            } while(reader.Read());
                        }
                        else
                            throw new Exception(string.Format("The record
was not found in 'Project' using the following criteria: {0}.", criteria));
                    }
                }
            }

            IsReadOnly = true;
            RaiseListChangedEvents = true;
        }

        #endregion

        #endregion
    }
}

Original issue reported on code.google.com by eirikur....@arionbanki.is on 18 May 2010 at 3:52

GoogleCodeExporter commented 9 years ago

Original comment by bniemyjski on 18 May 2010 at 3:57

GoogleCodeExporter commented 9 years ago
Hello,

This has been fixed in revision 1646.

Thanks
-Blake Niemyjski

Original comment by bniemyjski on 20 May 2010 at 5:03

GoogleCodeExporter commented 9 years ago

Original comment by bniemyjski on 21 Jun 2010 at 8:08

GoogleCodeExporter commented 9 years ago

Original comment by bniemyjski on 15 Jul 2010 at 2:21