Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Think i have part of my answer. By reading a lot more about TextTemplatesTransformations i have modified my Model1.tt to include: </p> <pre><code>System.ComponentModel.DataAnnotations; </code></pre> <p>i have also modified the WriteProperty method to accept an EdmPropertyType. The code now generates multiline annotations for all strings which came from a specified length > 60 or max defined strings. It also generates a maxlength annotation which should hopefully help prevent overflow. If using you will need to modify both the existing WriteProperty overloads as below.</p> <pre><code>void WriteProperty(CodeGenerationTools code, EdmProperty edmProperty) { WriteProperty(Accessibility.ForProperty(edmProperty), code.Escape(edmProperty.TypeUsage), code.Escape(edmProperty), code.SpaceAfter(Accessibility.ForGetter(edmProperty)), code.SpaceAfter(Accessibility.ForSetter(edmProperty)),edmProperty); } void WriteProperty(string accessibility, string type, string name, string getterAccessibility, string setterAccessibility,EdmProperty edmProperty = null) { if (type =="string") { int maxLength = 0;//66 bool bres = (edmProperty != null &amp;&amp; Int32.TryParse(edmProperty.TypeUsage.Facets["MaxLength"].Value.ToString(), out maxLength)); if (maxLength &gt; 60) // want to display as a TextArea in html { #&gt; [DataType(DataType.MultilineText)] [MaxLength(&lt;#=maxLength#&gt;)] &lt;#+ } else if (maxLength &lt; 61 &amp;&amp; maxLength &gt; 0) { #&gt; [MaxLength(&lt;#=maxLength#&gt;)] &lt;#+ } else if(maxLength &lt;=0) //varchar(max) { #&gt; [DataType(DataType.MultilineText)] &lt;#+ } } #&gt; &lt;#=accessibility#&gt; &lt;#=type#&gt; &lt;#=name#&gt; { &lt;#=getterAccessibility#&gt;get; &lt;#=setterAccessibility#&gt;set; } &lt;#+ } </code></pre> <p>Ensure that the &lt;#+ lines and the #> lines start at the begining of the line as i think this is a requirement of the TT syntax.</p> <p>Tim</p>
    singulars
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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