Changeset 2217 for branches/HeuristicLab.Modeling Database Backend/sources/HeuristicLab.Modeling.Database.SQLServerCompact
- Timestamp:
- 07/31/09 12:11:41 (15 years ago)
- Location:
- branches/HeuristicLab.Modeling Database Backend/sources/HeuristicLab.Modeling.Database.SQLServerCompact/3.2
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Modeling Database Backend/sources/HeuristicLab.Modeling.Database.SQLServerCompact/3.2/DataObjects/Model.cs
r2203 r2217 14 14 } 15 15 16 public Model(Variable targetVariable, Algorithm algorithm , byte[] data)16 public Model(Variable targetVariable, Algorithm algorithm) 17 17 : this() { 18 18 this.targetVariableId = targetVariable.Id; 19 19 this.algorithmId = algorithm.Id; 20 this.Data = data;21 20 } 22 21 … … 26 25 get { return this.id; } 27 26 private set { this.id = value; } 28 }29 30 private byte[] data;31 [Column(Storage = "data", DbType = "image", CanBeNull = false)]32 public byte[] Data {33 get { return this.data; }34 set { this.data = value; }35 27 } 36 28 -
branches/HeuristicLab.Modeling Database Backend/sources/HeuristicLab.Modeling.Database.SQLServerCompact/3.2/DatabaseService.cs
r2207 r2217 45 45 46 46 using (ModelingDataContext ctx = new ModelingDataContext(connection)) { 47 model = new Model(target, algo , PersistenceManager.SaveToGZip(algorithm.Model.Data));47 model = new Model(target, algo); 48 48 model.TrainingSamplesStart = trainingSamplesStart; 49 49 model.TrainingSamplesEnd = trainingSamplesEnd; … … 59 59 60 60 using (ModelingDataContext ctx = new ModelingDataContext(connection)) { 61 ctx.ModelData.InsertOnSubmit(new ModelData(model, PersistenceManager.SaveToGZip(algorithm.Model.Data))); 62 } 63 64 using (ModelingDataContext ctx = new ModelingDataContext(connection)) { 61 65 foreach (string inputVariable in algorithm.Model.InputVariables) { 62 ctx.InputVariables.InsertOnSubmit(new InputVariable(model, variables[inputVariable])); 66 ctx.InputVariables.InsertOnSubmit(new InputVariable(model, variables[inputVariable])); 63 67 } 64 68 ctx.SubmitChanges(); … … 194 198 195 199 public IEnumerable<IResult> GetAllResultsForInputVariables() { 196 using (ModelingDataContext ctx = new ModelingDataContext(connection) ){197 return (from ir in ctx.InputVariableResults 200 using (ModelingDataContext ctx = new ModelingDataContext(connection)) { 201 return (from ir in ctx.InputVariableResults select ir.Result).Distinct().ToList().Cast<IResult>(); 198 202 } 199 203 } … … 205 209 ModelingDataContext ctx = new ModelingDataContext(connection); 206 210 DataLoadOptions dlo = new DataLoadOptions(); 207 dlo.LoadWith<ModelResult>(mr => mr.Model);208 211 dlo.LoadWith<ModelResult>(mr => mr.Result); 209 212 ctx.LoadOptions = dlo; … … 214 217 return results.ToList().Cast<IModelResult>(); 215 218 } 219 220 public void GetAllModelResults() { 221 ModelingDataContext ctx = new ModelingDataContext(connection); 222 DataLoadOptions dlo = new DataLoadOptions(); 223 dlo.LoadWith<ModelResult>(mr => mr.Result); 224 dlo.LoadWith<ModelResult>(mr => mr.Model); 225 ctx.LoadOptions = dlo; 226 227 var results = from result in ctx.ModelResults 228 select result; 229 results.ToList(); 230 231 } 216 232 #endregion 217 233 … … 221 237 DataLoadOptions dlo = new DataLoadOptions(); 222 238 dlo.LoadWith<InputVariableResult>(ir => ir.Variable); 223 dlo.LoadWith<InputVariableResult>(ir => ir.Result); 224 dlo.LoadWith<InputVariableResult>(ir => ir.Model); 239 dlo.LoadWith<InputVariableResult>(ir => ir.Result); 225 240 ctx.LoadOptions = dlo; 226 241 … … 241 256 return ctx.Models.ToList().Cast<IModel>(); 242 257 } 258 259 public byte[] GetModelData(IModel model) { 260 using (ModelingDataContext ctx = new ModelingDataContext(connection)) { 261 var data = (from md in ctx.ModelData 262 where md.Model == model 263 select md); 264 if (data.Count() == 0) 265 return null; 266 return data.Single().Data; 267 } 268 } 243 269 #endregion 244 270 -
branches/HeuristicLab.Modeling Database Backend/sources/HeuristicLab.Modeling.Database.SQLServerCompact/3.2/HeuristicLab.Modeling.Database.SQLServerCompact-3.2.csproj
r2213 r2217 122 122 <Compile Include="DataObjects\InputVariableResult.cs" /> 123 123 <Compile Include="DataObjects\Model.cs" /> 124 <Compile Include="DataObjects\ModelData.cs" /> 124 125 <Compile Include="HeuristicLabModelingDatabaseSQLServerCompactPlugin.cs" /> 125 126 <Compile Include="ModelingDataContext.cs" /> -
branches/HeuristicLab.Modeling Database Backend/sources/HeuristicLab.Modeling.Database.SQLServerCompact/3.2/ModelingDataContext.cs
r2194 r2217 33 33 } 34 34 35 public Table<ModelData> ModelData { 36 get { return GetTable<ModelData>(); } 37 } 38 35 39 public Table<InputVariableResult> InputVariableResults { 36 40 get { return GetTable<InputVariableResult>(); }
Note: See TracChangeset
for help on using the changeset viewer.