Note that there are some explanatory texts on larger screens.

plurals
  1. POHelp Linq to Sql
    primarykey
    data
    text
    <p>Why am I getting a exception when ApplyPropertyChanges???</p> <p>The code is almost the same when I'm editing a user table but is not working with my news table.</p> <p>The create, delete and details are all working fine but when I try to edit a news I'm getting the exception below:</p> <p><strong>The ObjectStateManager does not contain a ObjectStateEntry 'MagixCMS.Models.noticia'</strong></p> <pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace MagixCMS.Models { public class NoticiaRepository : INoticiaRepository { #region INoticiaRepository Members magixcmsEntities _entities = new magixcmsEntities(); public noticia CreateNoticia(noticia noticiaToCreate) { _entities.AddTonoticiaSet(noticiaToCreate); _entities.SaveChanges(); return noticiaToCreate; } public void DeletaNoticia(noticia noticiaToDelete) { var noticiaOriginal = GetNoticia(noticiaToDelete.Id); _entities.DeleteObject(noticiaOriginal); _entities.SaveChanges(); } public noticia EditNoticia(noticia noticiaToEdit) { var noticiaOriginal = GetNoticia(noticiaToEdit.Id); _entities.ApplyPropertyChanges(noticiaToEdit.EntityKey.EntitySetName, noticiaToEdit); //EXCEPTION HERE _entities.SaveChanges(); return noticiaToEdit; } public noticia GetNoticia(int id) { return (from c in _entities.noticiaSet where c.Id == id select c).FirstOrDefault(); } public IEnumerable&lt;noticia&gt; ListNoticias() { return _entities.noticiaSet.ToList(); } #endregion } } </code></pre> <p>I google the exception and didn't found much help.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload