CodeSmith Community
Your Code. Your Way. Faster!

Plans to align VList with TList and View Entities with Table Entities

Latest post 11-27-2006 8:24 PM by MrBretticus. 2 replies.
  • 11-22-2006 9:42 PM

    • MrBretticus
    • Top 75 Contributor
    • Joined on 02-10-2006
    • Perth, Australia
    • Posts 54
    • Points 1,360

    Plans to align VList with TList and View Entities with Table Entities

    As the subject mentions it would be great to see this happen, and I thought I remembered a discussion about it quite awhile ago. However at the moment I'm having trouble with even simple tasks such as getting Table Column names. For IEntity you can just use .TableColumns, but for View Entities the best I could come up with (other than getting all public properties, which seems a bit dangerous as they may not all be columns in the future) is to do this:


    Type itemType = list[0].GetType();
    Type enumType = Type.GetType(String.Format("{0}Column, {1}", itemType.FullName, itemType.Namespace), false, true);

    if (enumType != null && enumType.BaseType.FullName == typeof(Enum).FullName) {
        return Enum.GetNames(enumType);
    }

    Is there anything in the works?
     

    Cheers, Brett "Most human beings have an almost infinite capacity for taking things for granted." - Aldous Huxley
    • Post Points: 35
  • 11-27-2006 3:17 PM In reply to

    • SuperJeffe
    • Top 25 Contributor
    • Joined on 05-05-2006
    • Tulsa, Ok
    • Posts 440
    • Points 10,980

    Re: Plans to align VList with TList and View Entities with Table Entities

    I am someone that doesn't like converting Enums to strings....my biggest reason is it won't work with Dotfuscation.  You will have to go through all your objects and exclude your enums from being dotfuscated.  Enums are values, not strings....they shouldn't be used like strings.  That's just me :)

    I modified the nettiers templated to include a ColumnNames struct with each string:  you can do the same if you like.  The only bad thing about modifying the templates is you have to do it everytime you update the templates.  I wish they would do it but they like the enums route.  Again, just my way of skinning the same cat.

    The syntax for once you have the generated object is Entity.ColumnNames.ColumnName.  It works well for us.

     Jeff

    Table Script(goes in EntityInstanceBase.generated.cst file inside the class definition somewhere):
      #region Column Name Struct
      /// <summary>
      /// List of columns and the string value for them.
      /// </summary>
      public struct ColumnNames
      {
       <% for (int x=0; x < cols.Count; x++) {  %>
       /// <summary>
       /// <%= GetPropertyName(cols[x].Name) %> :
       /// </summary>
       public const string <%= GetPropertyName(cols[x].Name) %> = "<%= GetPropertyName(cols[x].Name) %>";      
       <% } %>
      }
      #endregion

    View Script (goes in EntityViewBase.generated.cst):
      #region Column Name Struct
      /// <summary>
      /// List of columns and the string value for them.
      /// </summary>
      public struct ColumnNames
      {
       <% for (int x=0; x < SourceView.Columns.Count; x++) {  %>
       /// <summary>
       /// <%= GetPropertyName(SourceView.Columns[x].Name) %> :
       /// </summary>
       public const string <%= GetPropertyName(SourceView.Columns[x].Name) %> = "<%= GetPropertyName(SourceView.Columns[x].Name) %>";      
       <% } %>
      }
      #endregion

     

    ----------------------------------------------------------------------
     Member of the .NetTiers team | Visit http://www.nettiers.com
    ----------------------------------------------------------------------

    • Post Points: 35
  • 11-27-2006 8:24 PM In reply to

    • MrBretticus
    • Top 75 Contributor
    • Joined on 02-10-2006
    • Perth, Australia
    • Posts 54
    • Points 1,360

    Re: Plans to align VList with TList and View Entities with Table Entities

    That sounds like a nice solution that I could use instead of what I outlined previously, I'll definitely try it out. However my question still stands about whether there are plans to make view entity and lists more closely resemble tables entity and lists. I'm not saying to implement add / update / delete, just stuff like the .TableColumns and other relevant properties / methods.
    Cheers, Brett "Most human beings have an almost infinite capacity for taking things for granted." - Aldous Huxley
    • Post Points: 5
Page 1 of 1 (3 items) | RSS
Copyright © 2008 CodeSmith Tools, LLC
Powered by Community Server (Commercial Edition), by Telligent Systems