Note that there are some explanatory texts on larger screens.

plurals
  1. PORetrieving [DisplayName] DataAnnotation in T4 template
    primarykey
    data
    text
    <p>I have downloaded the <a href="http://nuget.org/packages/MvcScaffolding" rel="nofollow">MVCScaffolding</a> nuget package within VS2010. I am trying to retrieve a [DisplayName data annotation from my model in order to use it within the index.cs.t4 template.</p> <p>This page <a href="http://blog.stevensanderson.com/2011/01/28/mvcscaffolding-one-to-many-relationships/" rel="nofollow">OneToMany Relationships</a> has shown me how to modify the index template in order to provide a link which will take me to the controller index for my child objects. Which in this case from emails to emailrecipients. The problem is i have called my controllers emailcontroller and emailrecipientscontroller rather than their rather less descriptive tables names which i would prefer to hide anyway. i have equally decorated the metadataobject which the t4 template uses(tbl_My_unwieldytablename_emailMetadata) with this displayname (emailrecipients) dataannotation and i was hoping i could modify the template in order to replace the name for the relation to use the displayname which is my controller name i.e.</p> <pre><code>[MetadataType(typeof(tbl_My_unwieldytablename_emailMetadata))] public partial class tbl_My_unwieldytablename_email { internal sealed class tbl_My_unwieldytablename_emailMetadata { [ScaffoldColumn(false)] [Required(ErrorMessage="id is required")] public Int32 id { get; set; } [DataType(DataType.Date)] public DateTime send_date { get; set; } [StringLength(255)] public String title { get; set; } [DataType(DataType.MultilineText)] public String message { get; set; } [StringLength(50)] public String author { get; set; } [StringLength(80)] [DataType(DataType.EmailAddress)] public String author_email { get; set; } [DataType(DataType.MultilineText)] public String attachment { get; set; } [DataType(DataType.Date)] public DateTime created_date { get; set; } public Int32 batches { get; set; } [DataType(DataType.Date)] public DateTime complete_date { get; set; } [DisplayName("emailrecipients")] public EntityCollection&lt;tbl_My_unwieldytablename_email_recipients&gt; tbl_My_unwieldytablename_email_recipients { get; set; } } </code></pre> <p>Cheers Tim</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload