[2229] | 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 |
|
---|
| 22 | using System;
|
---|
[2180] | 23 | using System.Collections.Generic;
|
---|
| 24 | using System.Data.Linq;
|
---|
| 25 | using System.Data.Linq.Mapping;
|
---|
| 26 | using System.Text;
|
---|
| 27 |
|
---|
[2194] | 28 | namespace HeuristicLab.Modeling.Database.SQLServerCompact {
|
---|
[2180] | 29 | [Table(Name = "ModelResult")]
|
---|
[2197] | 30 | public class ModelResult : IModelResult {
|
---|
[2180] | 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() {
|
---|
[2203] | 38 | this.modelId = model.Id;
|
---|
| 39 | this.resultId = result.Id;
|
---|
[2180] | 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;
|
---|
[2200] | 51 | [Column(Storage = "modelId",IsPrimaryKey = true, CanBeNull = false)]
|
---|
[2180] | 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; }
|
---|
[2203] | 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 | //}
|
---|
[2180] | 79 | }
|
---|
| 80 |
|
---|
[2197] | 81 | IModel IModelResult.Model {
|
---|
| 82 | get { return this.Model; }
|
---|
| 83 | }
|
---|
| 84 |
|
---|
[2180] | 85 | private int resultId;
|
---|
[2200] | 86 | [Column(Storage = "resultId",IsPrimaryKey = true, CanBeNull = false)]
|
---|
[2180] | 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; }
|
---|
[2203] | 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 | //}
|
---|
[2180] | 114 | }
|
---|
| 115 |
|
---|
[2197] | 116 | IResult IModelResult.Result {
|
---|
| 117 | get { return this.Result; }
|
---|
| 118 | }
|
---|
| 119 |
|
---|
[2180] | 120 | }
|
---|
| 121 | }
|
---|