Exception in AttachCopy with computed columns

Thread is closed for posting
2 posts, 0 answers
  1. Bernd
    Bernd avatar
    92 posts
    Member since:
    Feb 2013

    Posted 30 Jan 2017 Link to this post

    Hello all.

    I have a table with computed columns. They are marked as such in the meta data source:

    configuration.HasProperty(x => x.EndWeek).WithDataAccessKind(DataAccessKind.ReadOnly).IsNullable();
    configuration.HasProperty(x => x.StartWeek).WithDataAccessKind(DataAccessKind.ReadOnly).IsNullable();
    configuration.HasProperty(x => x.Duration).WithDataAccessKind(DataAccessKind.ReadOnly).IsNullable();

    Performing an update via "AttachCopy" throws an exception.

    Telerik.OpenAccess.Exceptions.InvalidOperationException: The update of field 'idee5.Dispatcher.Model.DAL.CalendarEvent.<Duration>k__BackingField' is not allowed.
     
    Quellfehler:
     
     
    Zeile 66:       public CalendarEventViewModel Update(CalendarEventViewModel updatedObject) {
    Zeile 67:           CalendarEvent toBeUpdated =  _mapper.Map<CalendarEvent>(updatedObject);
    Zeile 68:             _db.AttachCopy(toBeUpdated);
    Zeile 69:           _db.SaveChanges();
    Zeile 70:           return updatedObject;

     

    How can I tell DataAccess to handle those computed columns correctly by ignoring changes?

    Thanks

    Bernd

  2. Bernd
    Bernd avatar
    92 posts
    Member since:
    Feb 2013

    Posted 12 Mar 2017 Link to this post

    Any ideas?
Back to Top