Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Modeling Database Backend/sources/HeuristicLab.Modeling.Database.SQLServerCompact/3.2/DataObjects/InputVariable.cs @ 2194

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

adapted HeuristicLab.Modeling.Database and Database.SQLServerCompact (ticket #712)

File size: 1.7 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Data.Linq;
4using System.Data.Linq.Mapping;
5using System.Text;
6
7namespace HeuristicLab.Modeling.Database.SQLServerCompact {
8  [Table(Name = "InputVariable")]
9  public class InputVariable : IInputVariable {
10    public InputVariable() {
11      this.model = default(EntityRef<Model>);
12      this.variable = default(EntityRef<Variable>);
13    }
14
15    public InputVariable(Model model, Variable variable)
16      : base() {
17      this.model.Entity = model;
18      this.variable.Entity = variable;
19    }
20
21    private int variableId;
22    [Column(Storage = "variableId", IsPrimaryKey = true)]
23    public int VariableId {
24      get { return this.variableId; }
25      private set {
26        if (variableId != value) {
27          if (variable.HasLoadedOrAssignedValue)
28            throw new ForeignKeyReferenceAlreadyHasValueException();
29          variableId = value;         
30        }
31      }
32    }
33
34    private EntityRef<Variable> variable;
35    [Association(Storage = "variable", ThisKey = "VariableId", OtherKey = "Id", IsForeignKey = true)]
36    public IVariable Variable {
37      get { return variable.Entity; }
38    }
39
40    private int modelId;
41    [Column(Storage = "modelId", IsPrimaryKey = true)]
42    public int ModelId {
43      get { return this.modelId; }
44      private set {
45        if (modelId != value) {
46          if (model.HasLoadedOrAssignedValue)
47            throw new ForeignKeyReferenceAlreadyHasValueException();
48          modelId = value;
49        }
50      }
51    }
52
53    private EntityRef<Model> model;
54    [Association(Storage = "model", ThisKey = "ModelId", OtherKey = "Id", IsForeignKey = true)]
55    public IModel Model {
56      get { return model.Entity; }
57    }
58  }
59}
Note: See TracBrowser for help on using the repository browser.