aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.CodeGeneration/Templates/EntityCodeFile.cshtml
blob: 4cdb1d6fab850ec226509cf26037536bdbce6b3b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Xml.Serialization;
using Newtonsoft.Json;
using System.Linq;
using Tango.DAL.Remote.DB;

namespace Tango.Integration.Observables
{
    [Table("@(Model.TableName)")]
    public partial class @(Model.Name) : ObservableEntity<@(Model.Name)>
    {
        @foreach (var prop in Model.Fields)
        {
    <div>
        protected @(prop.Type) _@(prop.Name.ToLower());
        /// <summary>
        /// Gets or sets the @(Model.Name.ToLower()) @(prop.Description).
        /// </summary>
        @(!prop.Construct && !prop.Complex ? "[Column(\"" + prop.FieldName + "\")]" : "")
        @(prop.IsForeignKey ? "[ForeignKey(\"" + prop.ForeignKeyName + "\")]" : "")
        @(prop.XmlIgnore ? "[XmlIgnore]" : "")
        @(prop.XmlIgnore ? "[JsonIgnore]" : "")
        public @(prop.Construct || prop.Complex ? "virtual" : "") @(prop.Type) @(prop.Name)
        {
            get { return _@(prop.Name.ToLower()); }
            set { _@(prop.Name.ToLower()) = value; RaisePropertyChanged(nameof(@(prop.Name))); }
        }
    </div>
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="@(Model.Name)" /> class.
        /// </summary>
        public @(Model.Name)() : base()
        {
            @foreach (var prop in Model.Fields)
            {
                if (prop.Construct)
                {
                    <div>
                        @(prop.Name) = new @(prop.Type)();
                    </div>
                }
            }
        }
    }
}