1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Linq;
|
---|
4 | using System.Data.Linq;
|
---|
5 | using System.Data.Linq.Mapping;
|
---|
6 | using System.Text;
|
---|
7 |
|
---|
8 | namespace 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 = "model", 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 IAlgorithm 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 = (Algorithm)value;
|
---|
61 | if (value != null) {
|
---|
62 | algorithmId = ((Algorithm)value).Id;
|
---|
63 | }
|
---|
64 | }
|
---|
65 | }
|
---|
66 | }
|
---|
67 |
|
---|
68 | private int targetVariableId;
|
---|
69 | [Column(Storage = "targetVariableId", CanBeNull = false)]
|
---|
70 | public int TargetVariableId {
|
---|
71 | get { return this.targetVariableId; }
|
---|
72 | private set {
|
---|
73 | if (targetVariableId != value) {
|
---|
74 | if (targetVariable.HasLoadedOrAssignedValue)
|
---|
75 | throw new ForeignKeyReferenceAlreadyHasValueException();
|
---|
76 | targetVariableId = value;
|
---|
77 | }
|
---|
78 | }
|
---|
79 | }
|
---|
80 |
|
---|
81 | private EntityRef<Variable> targetVariable;
|
---|
82 | [Association(Storage = "targetVariable", ThisKey = "TargetVariableId", OtherKey = "Id", IsForeignKey = true)]
|
---|
83 | public IVariable TargetVariable {
|
---|
84 | get { return this.targetVariable.Entity; }
|
---|
85 | private set {
|
---|
86 | Variable previousValue = targetVariable.Entity;
|
---|
87 | if (previousValue != value || (!targetVariable.HasLoadedOrAssignedValue)) {
|
---|
88 | if (previousValue != null) {
|
---|
89 | targetVariable.Entity = null;
|
---|
90 | }
|
---|
91 | targetVariable.Entity = (Variable)value;
|
---|
92 | if (value != null) {
|
---|
93 | targetVariableId = ((Variable)value).Id;
|
---|
94 | }
|
---|
95 | }
|
---|
96 | }
|
---|
97 | }
|
---|
98 |
|
---|
99 | private int trainingSamplesStart;
|
---|
100 | [Column(Storage = "trainingSamplesStart", CanBeNull = false)]
|
---|
101 | public int TrainingSamplesStart {
|
---|
102 | get { return this.trainingSamplesStart; }
|
---|
103 | set { this.trainingSamplesStart = value; }
|
---|
104 | }
|
---|
105 |
|
---|
106 | private int trainingSamplesEnd;
|
---|
107 | [Column(Storage = "trainingSamplesEnd", CanBeNull = false)]
|
---|
108 | public int TrainingSamplesEnd {
|
---|
109 | get { return this.trainingSamplesEnd; }
|
---|
110 | set { this.trainingSamplesEnd = value; }
|
---|
111 | }
|
---|
112 |
|
---|
113 | private int validationSamplesStart;
|
---|
114 | [Column(Storage = "validationSamplesStart", CanBeNull = false)]
|
---|
115 | public int ValidationSamplesStart {
|
---|
116 | get { return this.validationSamplesStart; }
|
---|
117 | set { this.validationSamplesStart = value; }
|
---|
118 | }
|
---|
119 |
|
---|
120 | private int validationSamplesEnd;
|
---|
121 | [Column(Storage = "validationSamplesEnd", CanBeNull = false)]
|
---|
122 | public int ValidationSamplesEnd {
|
---|
123 | get { return this.validationSamplesEnd; }
|
---|
124 | set { this.validationSamplesEnd = value; }
|
---|
125 | }
|
---|
126 |
|
---|
127 | private int testSamplesStart;
|
---|
128 | [Column(Storage = "testSamplesStart", CanBeNull = false)]
|
---|
129 | public int TestSamplesStart {
|
---|
130 | get { return this.testSamplesStart; }
|
---|
131 | set { this.testSamplesStart = value; }
|
---|
132 | }
|
---|
133 |
|
---|
134 | private int testSamplesEnd;
|
---|
135 | [Column(Storage = "testSamplesEnd", CanBeNull = false)]
|
---|
136 | public int TestSamplesEnd {
|
---|
137 | get { return this.testSamplesEnd; }
|
---|
138 | set { this.testSamplesEnd = value; }
|
---|
139 | }
|
---|
140 | }
|
---|
141 | }
|
---|