[2178] | 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.SQLiteBackend {
|
---|
| 9 | [Table(Name = "Variable")]
|
---|
| 10 | public class Variable {
|
---|
| 11 | public Variable() {
|
---|
| 12 | modelsPredictingThisVariable = new EntitySet<Model>(attach_Model, detach_Model);
|
---|
| 13 | }
|
---|
| 14 |
|
---|
| 15 | private int id;
|
---|
| 16 | [Column(Storage = "id", DbType = "integer", IsPrimaryKey = true, IsDbGenerated = true, UpdateCheck = UpdateCheck.Never)]
|
---|
| 17 | public int Id {
|
---|
| 18 | get { return this.id; }
|
---|
| 19 | private set { this.id = value; }
|
---|
| 20 | }
|
---|
| 21 |
|
---|
| 22 | private string name;
|
---|
| 23 | [Column(Storage = "name", DbType = "VarChar(50) NOT NULL", CanBeNull = false)]
|
---|
| 24 | public string Name {
|
---|
| 25 | get { return this.name; }
|
---|
| 26 | private set { this.name = value; }
|
---|
| 27 | }
|
---|
| 28 |
|
---|
| 29 | private EntitySet<Model> modelsPredictingThisVariable;
|
---|
| 30 | [Association(Storage = "modelsPredictingThisVariable", ThisKey = "Id", OtherKey = "TargetVariableId")]
|
---|
| 31 | public EntitySet<Model> ModelsPredictingThisVariable {
|
---|
| 32 | get {
|
---|
| 33 | if (modelsPredictingThisVariable.HasLoadedOrAssignedValues)
|
---|
| 34 | return modelsPredictingThisVariable;
|
---|
| 35 | return null;
|
---|
| 36 | }
|
---|
| 37 | set {
|
---|
| 38 | modelsPredictingThisVariable.Assign(value);
|
---|
| 39 | }
|
---|
| 40 | }
|
---|
| 41 |
|
---|
| 42 | private void attach_Model(Model model) {
|
---|
| 43 | model.TargetVariable = this;
|
---|
| 44 | }
|
---|
| 45 |
|
---|
| 46 | private void detach_Model(Model model) {
|
---|
| 47 | model.TargetVariable = null;
|
---|
| 48 | }
|
---|
| 49 |
|
---|
| 50 | public IEnumerable<Model> ModelsUsingThisVariable {
|
---|
| 51 | get {
|
---|
| 52 | using (ModelingDataContext ctx = new ModelingDataContext()) {
|
---|
| 53 | var x = from inputVariable in ctx.InputVariables
|
---|
| 54 | where inputVariable.Variable == this
|
---|
| 55 | select inputVariable.Model;
|
---|
| 56 | return x.AsEnumerable();
|
---|
| 57 | }
|
---|
| 58 | }
|
---|
| 59 | }
|
---|
| 60 | }
|
---|
| 61 | }
|
---|