Changeset 2179 for branches/HeuristicLab.Modeling Database Backend/sources/HeuristicLab.Modeling.SQLiteBackend/3.2/ModelResult.cs
- Timestamp:
- 07/23/09 11:01:40 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Modeling Database Backend/sources/HeuristicLab.Modeling.SQLiteBackend/3.2/ModelResult.cs
r2178 r2179 1 1 using System; 2 2 using System.Collections.Generic; 3 using System.Linq; 3 using System.Data.Linq; 4 using System.Data.Linq.Mapping; 4 5 using System.Text; 5 6 6 7 namespace HeuristicLab.Modeling.SQLiteBackend { 8 [Table(Name = "ModelResult")] 7 9 public class ModelResult { 10 public ModelResult() { 11 this.model = default(EntityRef<Model>); 12 this.result = default(EntityRef<Result>); 13 } 14 15 public ModelResult(Model model, Result result, double value) 16 : this() { 17 this.Model = model; 18 this.Result = result; 19 this.value = value; 20 } 21 22 private double value; 23 [Column(Storage = "value", CanBeNull = false)] 24 public double Value { 25 get { return this.value; } 26 set { this.value = value; } 27 } 28 29 private int modelId; 30 [Column(Storage = "modelId", CanBeNull = false)] 31 public int ModelId { 32 get { return this.modelId; } 33 private set { 34 if (modelId != value) { 35 if (model.HasLoadedOrAssignedValue) 36 throw new ForeignKeyReferenceAlreadyHasValueException(); 37 } 38 modelId = value; 39 } 40 } 41 42 private EntityRef<Model> model; 43 [Association(Storage = "model", ThisKey = "ModelId", OtherKey = "Id", IsForeignKey = true)] 44 public Model Model { 45 get { return this.model.Entity; } 46 set { 47 Model previousValue = model.Entity; 48 if (previousValue != value || (!model.HasLoadedOrAssignedValue)) { 49 if (previousValue != null) { 50 model.Entity = null; 51 } 52 model.Entity = value; 53 if (value != null) { 54 modelId = value.Id; 55 } 56 } 57 } 58 } 59 60 private int resultId; 61 [Column(Storage = "resultId", CanBeNull = false)] 62 public int ResultId { 63 get { return this.resultId; } 64 private set { 65 if (resultId != value) { 66 if (result.HasLoadedOrAssignedValue) 67 throw new ForeignKeyReferenceAlreadyHasValueException(); 68 } 69 modelId = value; 70 } 71 } 72 73 private EntityRef<Result> result; 74 [Association(Storage = "result", ThisKey = "ResultId", OtherKey = "Id", IsForeignKey = true)] 75 public Result Result { 76 get { return this.result.Entity; } 77 set { 78 Result previousValue = result.Entity; 79 if (previousValue != value || (!model.HasLoadedOrAssignedValue)) { 80 if (previousValue != null) { 81 result.Entity = null; 82 } 83 result.Entity = value; 84 if (value != null) { 85 resultId = value.Id; 86 } 87 } 88 } 89 } 90 8 91 } 9 92 }
Note: See TracChangeset
for help on using the changeset viewer.