Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Modeling.Database.SQLServerCompact/3.2/DataObjects/ModelResult.cs @ 3099

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

added license information (ticket #712)

File size: 3.7 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System;
23using System.Collections.Generic;
24using System.Data.Linq;
25using System.Data.Linq.Mapping;
26using System.Text;
27
28namespace HeuristicLab.Modeling.Database.SQLServerCompact {
29  [Table(Name = "ModelResult")]
30  public class ModelResult : IModelResult {
31    public ModelResult() {
32      this.model = default(EntityRef<Model>);
33      this.result = default(EntityRef<Result>);
34    }
35
36    public ModelResult(Model model, Result result, double value)
37      : this() {
38      this.modelId = model.Id;
39      this.resultId = result.Id;
40      this.value = value;
41    }
42
43    private double value;
44    [Column(Storage = "value", CanBeNull = false)]
45    public double Value {
46      get { return this.value; }
47      set { this.value = value; }
48    }
49
50    private int modelId;
51    [Column(Storage = "modelId",IsPrimaryKey = true, CanBeNull = false)]
52    public int ModelId {
53      get { return this.modelId; }
54      private set {
55        if (modelId != value) {
56          if (model.HasLoadedOrAssignedValue)
57            throw new ForeignKeyReferenceAlreadyHasValueException();
58        }
59        modelId = value;
60      }
61    }
62
63    private EntityRef<Model> model;
64    [Association(Storage = "model", ThisKey = "ModelId", OtherKey = "Id", IsForeignKey = true)]
65    public Model Model {
66      get { return this.model.Entity; }
67      //set {
68      //  Model previousValue = model.Entity;
69      //  if (previousValue != value || (!model.HasLoadedOrAssignedValue)) {
70      //    if (previousValue != null) {
71      //      model.Entity = null;
72      //    }
73      //    model.Entity = value;
74      //    if (value != null) {
75      //      modelId = value.Id;
76      //    }
77      //  }
78      //}
79    }
80
81    IModel IModelResult.Model {
82      get { return this.Model; }
83    }
84
85    private int resultId;
86    [Column(Storage = "resultId",IsPrimaryKey = true, CanBeNull = false)]
87    public int ResultId {
88      get { return this.resultId; }
89      private set {
90        if (resultId != value) {
91          if (result.HasLoadedOrAssignedValue)
92            throw new ForeignKeyReferenceAlreadyHasValueException();
93        }
94        modelId = value;
95      }
96    }
97
98    private EntityRef<Result> result;
99    [Association(Storage = "result", ThisKey = "ResultId", OtherKey = "Id", IsForeignKey = true)]
100    public Result Result {
101      get { return this.result.Entity; }
102      //set {
103      //  Result previousValue = result.Entity;
104      //  if (previousValue != value || (!model.HasLoadedOrAssignedValue)) {
105      //    if (previousValue != null) {
106      //      result.Entity = null;
107      //    }
108      //    result.Entity = value;
109      //    if (value != null) {
110      //      resultId = value.Id;
111      //    }
112      //  }
113      //}
114    }
115
116    IResult IModelResult.Result {
117      get { return this.Result; }
118    }
119
120  }
121}
Note: See TracBrowser for help on using the repository browser.