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 @ 2203

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

corrected bugs in database sqlservercompact (ticket #712)

File size: 1.9 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.modelId = model.Id;
18      this.variableId = variable.Id;
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 Variable Variable {
37      get { return variable.Entity; }
38    }
39
40    IVariable IInputVariable.Variable {
41      get { return this.Variable; }
42    }
43
44    private int modelId;
45    [Column(Storage = "modelId", IsPrimaryKey = true)]
46    public int ModelId {
47      get { return this.modelId; }
48      private set {
49        if (modelId != value) {
50          if (model.HasLoadedOrAssignedValue)
51            throw new ForeignKeyReferenceAlreadyHasValueException();
52          modelId = value;
53        }
54      }
55    }
56
57    private EntityRef<Model> model;
58    [Association(Storage = "model", ThisKey = "ModelId", OtherKey = "Id", IsForeignKey = true)]
59    public Model Model {
60      get { return model.Entity; }
61    }
62
63    IModel IInputVariable.Model {
64      get { return this.Model;}
65    }
66  }
67}
Note: See TracBrowser for help on using the repository browser.