Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Modeling Database Backend/sources/HeuristicLab.Modeling.Database.SQLServerCompact/3.2/DataObjects/Model.cs @ 2197

Last change on this file since 2197 was 2197, checked in by mkommend, 15 years ago

adapted connection string and explicitly implemented the defined interfaces in hl.modeling.database (ticket #712)

File size: 4.7 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Data.Linq;
5using System.Data.Linq.Mapping;
6using System.Text;
7
8namespace HeuristicLab.Modeling.Database.SQLServerCompact {
9  [Table(Name = "Model")]
10  public class Model : IModel {
11    public Model() {
12      targetVariable = default(EntityRef<Variable>);
13      algorithm = default(EntityRef<Algorithm>);
14    }
15
16    public Model(Variable targetVariable, Algorithm algorithm, byte[] data)
17      : this() {
18      this.TargetVariable = targetVariable;
19      this.Algorithm = algorithm;
20      this.Data = data;
21    }
22
23    private int id;
24    [Column(Storage = "id", IsPrimaryKey = true, IsDbGenerated = true)]
25    public int Id {
26      get { return this.id; }
27      private set { this.id = value; }
28    }
29
30    private byte[] data;
31    [Column(Storage = "data", DbType = "image", CanBeNull = false)]
32    public byte[] Data {
33      get { return this.data; }
34      set { this.data = value; }
35    }
36
37    private int algorithmId;
38    [Column(Storage = "algorithmId", CanBeNull = false)]
39    public int AlgorithmId {
40      get { return this.algorithmId; }
41      private set {
42        if (algorithmId != value) {
43          if (algorithm.HasLoadedOrAssignedValue)
44            throw new ForeignKeyReferenceAlreadyHasValueException();
45          algorithmId = value;
46        }
47      }
48    }
49
50    private EntityRef<Algorithm> algorithm;
51    [Association(Storage = "algorithm", ThisKey = "AlgorithmId", OtherKey = "Id", IsForeignKey = true)]
52    public Algorithm Algorithm {
53      get { return this.algorithm.Entity; }
54      private set {
55        Algorithm previousValue = algorithm.Entity;
56        if (previousValue != value || (!algorithm.HasLoadedOrAssignedValue)) {
57          if (previousValue != null) {
58            algorithm.Entity = null;
59          }
60          algorithm.Entity =value;
61          if (value != null) {
62            algorithmId = value.Id;
63          }
64        }
65      }
66    }
67
68    IAlgorithm IModel.Algorithm {
69      get { return this.Algorithm; }
70    }
71
72    private int targetVariableId;
73    [Column(Storage = "targetVariableId", CanBeNull = false)]
74    public int TargetVariableId {
75      get { return this.targetVariableId; }
76      private set {
77        if (targetVariableId != value) {
78          if (targetVariable.HasLoadedOrAssignedValue)
79            throw new ForeignKeyReferenceAlreadyHasValueException();
80          targetVariableId = value;
81        }
82      }
83    }
84
85    private EntityRef<Variable> targetVariable;
86    [Association(Storage = "targetVariable", ThisKey = "TargetVariableId", OtherKey = "Id", IsForeignKey = true)]
87    public Variable TargetVariable {
88      get { return this.targetVariable.Entity; }
89      private set {
90        Variable previousValue = targetVariable.Entity;
91        if (previousValue != value || (!targetVariable.HasLoadedOrAssignedValue)) {
92          if (previousValue != null) {
93            targetVariable.Entity = null;
94          }
95          targetVariable.Entity = value;
96          if (value != null) {
97            targetVariableId = value.Id;
98          }
99        }
100      }
101    }
102
103    IVariable IModel.TargetVariable {
104      get { return this.TargetVariable; }
105    }
106
107    private int trainingSamplesStart;
108    [Column(Storage = "trainingSamplesStart", CanBeNull = false)]
109    public int TrainingSamplesStart {
110      get { return this.trainingSamplesStart; }
111      set { this.trainingSamplesStart = value; }
112    }
113
114    private int trainingSamplesEnd;
115    [Column(Storage = "trainingSamplesEnd", CanBeNull = false)]
116    public int TrainingSamplesEnd {
117      get { return this.trainingSamplesEnd; }
118      set { this.trainingSamplesEnd = value; }
119    }
120
121    private int validationSamplesStart;
122    [Column(Storage = "validationSamplesStart", CanBeNull = false)]
123    public int ValidationSamplesStart {
124      get { return this.validationSamplesStart; }
125      set { this.validationSamplesStart = value; }
126    }
127
128    private int validationSamplesEnd;
129    [Column(Storage = "validationSamplesEnd", CanBeNull = false)]
130    public int ValidationSamplesEnd {
131      get { return this.validationSamplesEnd; }
132      set { this.validationSamplesEnd = value; }
133    }
134
135    private int testSamplesStart;
136    [Column(Storage = "testSamplesStart", CanBeNull = false)]
137    public int TestSamplesStart {
138      get { return this.testSamplesStart; }
139      set { this.testSamplesStart = value; }
140    }
141
142    private int testSamplesEnd;
143    [Column(Storage = "testSamplesEnd", CanBeNull = false)]
144    public int TestSamplesEnd {
145      get { return this.testSamplesEnd; }
146      set { this.testSamplesEnd = value; }
147    }
148  }
149}
Note: See TracBrowser for help on using the repository browser.