aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.CodeGeneration/Templates/EntityCodeFile.cshtml
blob: 9d5ac4bb12ccae5bba55247124f7829f3caeffe1 (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
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using Tango.DAL.Remote.DB;

namespace Tango.DAL.Observables
{
    [Table("@(Model.TableName)")]
    public partial class @(Model.Name) : ObservableEntity<@(Model.Name)>
    {
        @foreach (var prop in Model.Fields)
        {
    <div>
        private @(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 + "\")]" : "")
        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>
                }
            }
        }
    }
}