CodeSmith Community
Your Code. Your Way. Faster!

Is possible to use a map as a property type?

Latest post 01-25-2008 10:23 AM by ejsmith. 1 replies.
  • 01-24-2008 3:34 PM

    • dave1
    • Not Ranked
    • Joined on 09-18-2007
    • Tampa,FL
    • Posts 2
    • Points 70

    Is possible to use a map as a property type?

    I created a map called TableNameToEntity, using CodeSmiths map editor. The key consists of table names. The value consists of the name of the entity that will be generated.

    I'm trying to get it so that when running a template the user/programmer will choose which tables get processed from the mapping file.

    The main reason I'm doing this is because I can't depend on the singular/plural algorithm to generate the proper entity names.

    Anybody know if this is possible? Is there a better approach that would achieve the same results?I AM NOT USING NET TIERS.


    Below is a sample of the XML.

    <?xml version="1.0" encoding="utf-8"?>
    <codeSmith xmlns="http://www.codesmithtools.com/schema/csmap.xsd">
      <map caseSensitive="true" returnKeyWhenNotFound="false" description="BeerHouseTableNameToEntity">
        <item>
          <key>tbh_Articles</key>
          <value>Article</value>
        </item>
        <item>
          <key>tbh_Departments</key>
          <value>Department</value>
        </item>
      </map>
    </codeSmith>

     

    • Post Points: 35
  • 01-25-2008 10:23 AM In reply to

    • ejsmith
    • Top 10 Contributor
    • Joined on 12-28-2002
    • Dallas, TX USA
    • Posts 2,197
    • Points 922,380

    Re: Is possible to use a map as a property type?

    This is a perfectly good use of the maps feature.  What you could do is when you are looping through your source table, check to see if the key exists in the map.  If it does, generate the code for the table, if not, then don't generate anything.  Does that make sense?

    Eric J. Smith
    CodeSmith Tools, LLC
    Chief Software Architect

    • Post Points: 5
Page 1 of 1 (2 items) | RSS
Copyright © 2008 CodeSmith Tools, LLC
Powered by Community Server (Commercial Edition), by Telligent Systems