Changeset 2203
- Timestamp:
- 07/29/09 10:50:41 (15 years ago)
- Location:
- branches/HeuristicLab.Modeling Database Backend/sources
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Modeling Database Backend/sources/HeuristicLab.CEDMA.Core/3.3/Console.cs
r2194 r2203 34 34 namespace HeuristicLab.CEDMA.Core { 35 35 public class Console : ItemBase, IEditable { 36 private static readonly string sqlServerCompactFile = AppDomain.CurrentDomain.BaseDirectory + "HeuristicLab.Modeling.database ";36 private static readonly string sqlServerCompactFile = AppDomain.CurrentDomain.BaseDirectory + "HeuristicLab.Modeling.database.sdf"; 37 37 private static readonly string sqlServerCompactConnectionString = @"Data Source=" + sqlServerCompactFile; 38 38 -
branches/HeuristicLab.Modeling Database Backend/sources/HeuristicLab.Modeling.Database.SQLServerCompact/3.2/DataObjects/InputVariable.cs
r2197 r2203 15 15 public InputVariable(Model model, Variable variable) 16 16 : base() { 17 this.model .Entity = model;18 this.variable .Entity = variable;17 this.modelId = model.Id; 18 this.variableId = variable.Id; 19 19 } 20 20 -
branches/HeuristicLab.Modeling Database Backend/sources/HeuristicLab.Modeling.Database.SQLServerCompact/3.2/DataObjects/InputVariableResult.cs
r2197 r2203 16 16 public InputVariableResult(InputVariable inputVariable, Result result, double value) 17 17 : this() { 18 this.variable .Entity = (Variable)inputVariable.Variable;19 this.model .Entity = (Model)inputVariable.Model;20 this.result .Entity = result;18 this.variableId = inputVariable.VariableId; 19 this.modelId = inputVariable.ModelId; 20 this.resultId = result.Id; 21 21 this.value = value; 22 22 } -
branches/HeuristicLab.Modeling Database Backend/sources/HeuristicLab.Modeling.Database.SQLServerCompact/3.2/DataObjects/Model.cs
r2197 r2203 16 16 public Model(Variable targetVariable, Algorithm algorithm, byte[] data) 17 17 : this() { 18 this. TargetVariable = targetVariable;19 this. Algorithm = algorithm;18 this.targetVariableId = targetVariable.Id; 19 this.algorithmId = algorithm.Id; 20 20 this.Data = data; 21 21 } … … 52 52 public Algorithm Algorithm { 53 53 get { return this.algorithm.Entity; } 54 private set {55 Algorithm previousValue = algorithm.Entity;56 if (previousValue != value || (!algorithm.HasLoadedOrAssignedValue)) {57 if (previousValue != null) {58 algorithm.Entity = null;59 }60 algorithm.Entity =value;61 if (value != null) {62 algorithmId = value.Id;63 }64 }65 }54 //private set { 55 // Algorithm previousValue = algorithm.Entity; 56 // if (previousValue != value || (!algorithm.HasLoadedOrAssignedValue)) { 57 // if (previousValue != null) { 58 // algorithm.Entity = null; 59 // } 60 // algorithm.Entity = value; 61 // if (value != null) { 62 // algorithmId = value.Id; 63 // } 64 // } 65 //} 66 66 } 67 67 … … 87 87 public Variable TargetVariable { 88 88 get { return this.targetVariable.Entity; } 89 private set {90 Variable previousValue = targetVariable.Entity;91 if (previousValue != value || (!targetVariable.HasLoadedOrAssignedValue)) {92 if (previousValue != null) {93 targetVariable.Entity = null;94 }95 targetVariable.Entity = value;96 if (value != null) {97 targetVariableId = value.Id;98 }99 }100 }89 //private set { 90 // Variable previousValue = targetVariable.Entity; 91 // if (previousValue != value || (!targetVariable.HasLoadedOrAssignedValue)) { 92 // if (previousValue != null) { 93 // targetVariable.Entity = null; 94 // } 95 // targetVariable.Entity = value; 96 // if (value != null) { 97 // targetVariableId = value.Id; 98 // } 99 // } 100 //} 101 101 } 102 102 -
branches/HeuristicLab.Modeling Database Backend/sources/HeuristicLab.Modeling.Database.SQLServerCompact/3.2/DataObjects/ModelResult.cs
r2200 r2203 15 15 public ModelResult(Model model, Result result, double value) 16 16 : this() { 17 this. Model = model;18 this. Result = result;17 this.modelId = model.Id; 18 this.resultId = result.Id; 19 19 this.value = value; 20 20 } … … 44 44 public Model Model { 45 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 }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 58 } 59 59 … … 79 79 public Result Result { 80 80 get { return this.result.Entity; } 81 set {82 Result previousValue = result.Entity;83 if (previousValue != value || (!model.HasLoadedOrAssignedValue)) {84 if (previousValue != null) {85 result.Entity = null;86 }87 result.Entity = value;88 if (value != null) {89 resultId = value.Id;90 }91 }92 }81 //set { 82 // Result previousValue = result.Entity; 83 // if (previousValue != value || (!model.HasLoadedOrAssignedValue)) { 84 // if (previousValue != null) { 85 // result.Entity = null; 86 // } 87 // result.Entity = value; 88 // if (value != null) { 89 // resultId = value.Id; 90 // } 91 // } 92 //} 93 93 } 94 94 -
branches/HeuristicLab.Modeling Database Backend/sources/HeuristicLab.Modeling.Database.SQLServerCompact/3.2/DatabaseService.cs
r2194 r2203 54 54 55 55 ctx.Models.InsertOnSubmit(model); 56 57 ctx.SubmitChanges(); 58 } 59 60 using (ModelingDataContext ctx = new ModelingDataContext(connection)) { 56 61 foreach (string inputVariable in algorithm.Model.InputVariables) { 57 62 ctx.InputVariables.InsertOnSubmit(new InputVariable(model, variables[inputVariable])); 58 63 } 59 ctx.SubmitChanges();60 64 } 61 65 … … 69 73 ctx.ModelResults.InsertOnSubmit(new ModelResult(model, result, value)); 70 74 } 71 75 ctx.SubmitChanges(); 76 } 77 78 using (ModelingDataContext ctx = new ModelingDataContext(connection)) { 72 79 IEnumerable<MethodInfo> inputVariableResultInfos = algorithm.Model.GetType().GetMethods().Where( 73 80 info => info.GetParameters().Count() == 1 && … … 95 102 throw new InvalidOperationException("Could not get dataset. No or more than one problems are persisted in the database."); 96 103 97 Problem problem = ctx.Problems. ElementAt(0);104 Problem problem = ctx.Problems.Single(); 98 105 return problem.Dataset; 99 106 } … … 181 188 public IEnumerable<IResult> GetAllResults() { 182 189 using (ModelingDataContext ctx = new ModelingDataContext(connection)) { 183 return ctx.Results. AsEnumerable().Cast<IResult>();190 return ctx.Results.ToList().Cast<IResult>(); 184 191 } 185 192 } … … 198 205 where result.Model == model 199 206 select result; 200 return results. AsEnumerable().Cast<IModelResult>();207 return results.ToList().Cast<IModelResult>(); 201 208 } 202 209 #endregion … … 204 211 #region Model 205 212 public IEnumerable<IModel> GetAllModels() { 206 using (ModelingDataContext ctx = new ModelingDataContext(connection)) { 207 return ctx.Models.AsEnumerable().Cast<IModel>(); 208 } 213 ModelingDataContext ctx = new ModelingDataContext(connection); 214 DataLoadOptions dlo = new DataLoadOptions(); 215 dlo.LoadWith<Model>(m => m.TargetVariable); 216 ctx.LoadOptions = dlo; 217 return ctx.Models.ToList().Cast<IModel>(); 209 218 } 210 219 #endregion
Note: See TracChangeset
for help on using the changeset viewer.