Free cookie consent management tool by TermsFeed Policy Generator

Changeset 2390 for trunk/sources


Ignore:
Timestamp:
09/25/09 11:11:12 (15 years ago)
Author:
mkommend
Message:

correctd bug in persistence of models (ticket #759)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Modeling.Database.SQLServerCompact/3.2/DatabaseService.cs

    r2389 r2390  
    121121      using (ModelingDataContext ctx = new ModelingDataContext(connection)) {
    122122        Model m = (Model)model;
    123         Model orginal = ctx.Models.GetOriginalEntityState(m);
    124         if (orginal == null)
    125           ctx.Models.Attach(m);
    126         ctx.Refresh(RefreshMode.KeepCurrentValues, m);
     123        //check if model has to be updated or inserted
     124        if (ctx.Models.Any(x => x.Id == model.Id)) {
     125          Model orginal = ctx.Models.GetOriginalEntityState(m);
     126          if (orginal == null)
     127            ctx.Models.Attach(m);
     128          ctx.Refresh(RefreshMode.KeepCurrentValues, m);
     129        } else
     130          ctx.Models.InsertOnSubmit(m);
    127131        ctx.SubmitChanges();
    128132      }
Note: See TracChangeset for help on using the changeset viewer.