locked
Determining the pluralised name RRS feed

  • Question

  • User1816145733 posted

    I've got a table named 'tblThirdParty', which using the attributes I given the display name 'Third Party', what is the name of the entity or custom page that the dynamic data model will be looking for? I'm assuming its some variation on 'Third Parties', but it can't have a space in it can it?  as it'll be used for classes etc.

    Can I use the non-display name for the objects? like the page templates, the entity templates etc?  

    Is there a property of the MetaTable object I can query?

    Tuesday, March 22, 2011 1:43 PM

Answers

  • User232504566 posted

    Ah i sort of get you.

    The only this is your right, the display name doesnt control the naming convention of the entity templates.

    save you have tblBlah, its correct the nameing convention for the entity template should be tbBlahs.

    If you set [DisplayName("The Blah")] The entity Template and custom pages folder should still be called tblBlahs.

     

    Don't mistake the [DisplayName()] attribute with the [TableName()] attribute. The table name attribute will physically change the name of the table and thus change the naming standards of the entity and custom page templates.

     

    Hope that helps

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, March 23, 2011 9:34 AM

All replies

  • User232504566 posted

    I'm a tad bit confused on the question. From what i understand your asking how to attain the physical name of the entity from code behind?

    you can do this from meta table by [tableName].Name.

    You can also call from Column.Table.Name  as well.

     

    The Display name attribute is only used when calling the table. it will be used as a display option instead of the physical name given from the database. it isnt used for calling entities or the like its used soley for display purposes. you can compare display names as well the same was as i showed but with the .DisplayName property instead.

    Tuesday, March 22, 2011 1:57 PM
  • User1816145733 posted

    ah, no. I mean in the MSDN it gives the example of:

    If you are using the LINQ to SQL data model to represent the AdventureWorksLT database, entity templates for the Address table would be named Addresses.ascx, Addresses_Edit.ascx and Addresses_Insert.ascx.

    Now the first thing from what I can tell is that if you had a tablename of 'tblBlah' and a Linq2SQL entity of 'tblBlah', and you wanted to create a custom page template you would create a folder named 'tblBlahs' in the CustomPages folder. (This worked)

    But if you added the metadata DisplayName("Blah") to the Linq2SQL entity, the folder name would have to be 'Blah'.  Similarly for any entity templates for that table. (It's this that threw me, I'd expect the folder/entity template naming to based on the underlying things, not a presentation name, but it worked, so I carried on.)

    Am I right so far?

    My question is what if you want the DisplayName to be presentable i.e. "The Blahs" (wishing I'd picked a better example table name now Laughing), so the underlying entity and table are still 'tblBlah'.

    What should I use for the CustomPages folder name and entity templates?  I can't use spaces surely? Basically I'm after the rules it uses when the display name doesn't comply with naming standards for files, classes etc.

    Is that clearer?

     

     

     

     

     

    Wednesday, March 23, 2011 6:14 AM
  • User232504566 posted

    Ah i sort of get you.

    The only this is your right, the display name doesnt control the naming convention of the entity templates.

    save you have tblBlah, its correct the nameing convention for the entity template should be tbBlahs.

    If you set [DisplayName("The Blah")] The entity Template and custom pages folder should still be called tblBlahs.

     

    Don't mistake the [DisplayName()] attribute with the [TableName()] attribute. The table name attribute will physically change the name of the table and thus change the naming standards of the entity and custom page templates.

     

    Hope that helps

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, March 23, 2011 9:34 AM
  • User443262777 posted

    Thank you. I think that you're question is quite interesting. If when you build your data model you didn't uncheck the "pluralize" option then it will be pluralized in your model metadata code behind file, something like <whatever.edmx.cs>. So if the name of your table was "product" it will become "products" instead. If you uncheck that little box then your names will remain as you had them until now

    Wednesday, March 23, 2011 9:40 AM
  • User-330204900 posted

    Don't mistake the [DisplayName()] attribute with the [TableName()] attribute. The table name attribute will physically change the name of the table and thus change the naming standards of the entity and custom page templates.
    good point weel put Smile

    Wednesday, March 23, 2011 2:58 PM
  • User1816145733 posted
    It was the use of TableName v DisplayName, I'd added Sys.Component.Model.DataAnnotations, saw the TableName attribute and used that...not realising that there was another set of attributes that would also apply.
    Thursday, March 24, 2011 4:30 AM