Free cookie consent management tool by TermsFeed Policy Generator

Changeset 2203


Ignore:
Timestamp:
07/29/09 10:50:41 (15 years ago)
Author:
mkommend
Message:

corrected bugs in database sqlservercompact (ticket #712)

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  
    3434namespace HeuristicLab.CEDMA.Core {
    3535  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";
    3737    private static readonly string sqlServerCompactConnectionString = @"Data Source=" + sqlServerCompactFile;
    3838
  • branches/HeuristicLab.Modeling Database Backend/sources/HeuristicLab.Modeling.Database.SQLServerCompact/3.2/DataObjects/InputVariable.cs

    r2197 r2203  
    1515    public InputVariable(Model model, Variable variable)
    1616      : base() {
    17       this.model.Entity = model;
    18       this.variable.Entity = variable;
     17      this.modelId = model.Id;
     18      this.variableId = variable.Id;
    1919    }
    2020
  • branches/HeuristicLab.Modeling Database Backend/sources/HeuristicLab.Modeling.Database.SQLServerCompact/3.2/DataObjects/InputVariableResult.cs

    r2197 r2203  
    1616    public InputVariableResult(InputVariable inputVariable, Result result, double value)
    1717      : 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;
    2121      this.value = value;
    2222    }
  • branches/HeuristicLab.Modeling Database Backend/sources/HeuristicLab.Modeling.Database.SQLServerCompact/3.2/DataObjects/Model.cs

    r2197 r2203  
    1616    public Model(Variable targetVariable, Algorithm algorithm, byte[] data)
    1717      : this() {
    18       this.TargetVariable = targetVariable;
    19       this.Algorithm = algorithm;
     18      this.targetVariableId = targetVariable.Id;
     19      this.algorithmId = algorithm.Id;
    2020      this.Data = data;
    2121    }
     
    5252    public Algorithm Algorithm {
    5353      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      //}
    6666    }
    6767
     
    8787    public Variable TargetVariable {
    8888      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      //}
    101101    }
    102102
  • branches/HeuristicLab.Modeling Database Backend/sources/HeuristicLab.Modeling.Database.SQLServerCompact/3.2/DataObjects/ModelResult.cs

    r2200 r2203  
    1515    public ModelResult(Model model, Result result, double value)
    1616      : this() {
    17       this.Model = model;
    18       this.Result = result;
     17      this.modelId = model.Id;
     18      this.resultId = result.Id;
    1919      this.value = value;
    2020    }
     
    4444    public Model Model {
    4545      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      //}
    5858    }
    5959
     
    7979    public Result Result {
    8080      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      //}
    9393    }
    9494
  • branches/HeuristicLab.Modeling Database Backend/sources/HeuristicLab.Modeling.Database.SQLServerCompact/3.2/DatabaseService.cs

    r2194 r2203  
    5454
    5555        ctx.Models.InsertOnSubmit(model);
     56
     57        ctx.SubmitChanges();
     58      }
     59
     60      using (ModelingDataContext ctx = new ModelingDataContext(connection)) {
    5661        foreach (string inputVariable in algorithm.Model.InputVariables) {
    5762          ctx.InputVariables.InsertOnSubmit(new InputVariable(model, variables[inputVariable]));
    5863        }
    59         ctx.SubmitChanges();
    6064      }
    6165
     
    6973          ctx.ModelResults.InsertOnSubmit(new ModelResult(model, result, value));
    7074        }
    71 
     75        ctx.SubmitChanges();
     76      }
     77
     78      using (ModelingDataContext ctx = new ModelingDataContext(connection)) {
    7279        IEnumerable<MethodInfo> inputVariableResultInfos = algorithm.Model.GetType().GetMethods().Where(
    7380          info => info.GetParameters().Count() == 1 &&
     
    95102          throw new InvalidOperationException("Could not get dataset. No or more than one problems are persisted in the database.");
    96103
    97         Problem problem = ctx.Problems.ElementAt(0);
     104        Problem problem = ctx.Problems.Single();
    98105        return problem.Dataset;
    99106      }
     
    181188    public IEnumerable<IResult> GetAllResults() {
    182189      using (ModelingDataContext ctx = new ModelingDataContext(connection)) {
    183         return ctx.Results.AsEnumerable().Cast<IResult>();
     190        return ctx.Results.ToList().Cast<IResult>();
    184191      }
    185192    }
     
    198205                    where result.Model == model
    199206                    select result;
    200       return results.AsEnumerable().Cast<IModelResult>();
     207      return results.ToList().Cast<IModelResult>();
    201208    }
    202209    #endregion
     
    204211    #region Model
    205212    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>();
    209218    }
    210219    #endregion
Note: See TracChangeset for help on using the changeset viewer.