Note that there are some explanatory texts on larger screens.

plurals
  1. POASP .NET MVC + LINQ Generated Classes + DataAnnotations
    primarykey
    data
    text
    <p>I have a problem, and i hope, u can help me with it. Ok, i'll try to describe my situation:</p> <p>I've created database. Added table "Orders". Then generated LINQ Classes in dbml file.</p> <p>Now, i have create action in controller, and i'm trying to set [DisplayName("Other name")] for one or my Order class property (Client name). So, look at this:</p> <p><strong>/ Core / Extansions.cs</strong></p> <pre><code>namespace SUPNew.Core { public static class Extansions { } [MetadataType(typeof(OrderMetaData))] public partial class Order { } public class OrderMetaData { [DisplayName("ФИО клиента")] public string ClientFIO { get; set; } } } </code></pre> <p><strong>/ Views / Manager / AddOrder.aspx</strong></p> <pre><code> &lt;legend&gt;Fields&lt;/legend&gt; &lt;div class="editor-label"&gt; &lt;%: Html.LabelFor(model =&gt; model.ClientFIO) %&gt; &lt;/div&gt; &lt;div class="editor-field"&gt; &lt;%: Html.TextBoxFor(model =&gt; model.ClientFIO) %&gt; &lt;%: Html.ValidationMessageFor(model =&gt; model.ClientFIO) %&gt; &lt;/div&gt; </code></pre> <p><strong>/ Controllers / ManagerController.cs</strong></p> <pre><code>using SUPNew.Core; </code></pre> <p><strong>/ Models / SUPNew.dbml</strong></p> <pre><code> public partial class Order : INotifyPropertyChanging, INotifyPropertyChanged { ... [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_ClientFIO", DbType="NVarChar(50) NOT NULL", CanBeNull=false)] public string ClientFIO { get { return this._ClientFIO; } set { if ((this._ClientFIO != value)) { this.OnClientFIOChanging(value); this.SendPropertyChanging(); this._ClientFIO = value; this.SendPropertyChanged("ClientFIO"); this.OnClientFIOChanged(); } } } </code></pre> <p>So, maybe i forgot to make something? I need to display DisplayName for ClientFIO in LabelFor(model => model.ClientFIO) that i've choosen in partial class.</p> <p>Thx for help.</p> <hr> <p>If i change .dbml file- adding [DisplayName("OtherName")] like this:</p> <pre><code>[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_ClientFIO", DbType="NVarChar(50) NOT NULL", CanBeNull=false)] [DisplayName("Other name")] public string ClientFIO { get { return this._ClientFIO; } set { if ((this._ClientFIO != value)) { this.OnClientFIOChanging(value); this.SendPropertyChanging(); this._ClientFIO = value; this.SendPropertyChanged("ClientFIO"); this.OnClientFIOChanged(); } } } </code></pre> <p>it works, but when i try to make partial class- isn't. Can somebody help me with partial class for LINQ generated class?</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.
 

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