Note that there are some explanatory texts on larger screens.

plurals
  1. POSilverlight 4 RIA service issue
    primarykey
    data
    text
    <p>Hi I have created a sample database application in Silverlight by following a tutorial. I am trying to insert a record in DB but it throws an error <strong>Submit operation failed validation. Please inspect Entity.ValidationErrors for each entity in EntitiesInError for more information</strong>. I am using Entity framework for DAL. My code is given below. Exception occure when I insert a record. But Iam not sure at which stage exception occurs. RecordInsertPage.cs file</p> <pre><code>public partial class BookRegistaeration : ChildWindow { public Book newBook { get; set; } public BookRegistaeration() { InitializeComponent(); newBook = new Book(); AddBookForm.CurrentItem =AddBookForm; AddBookForm.BeginEdit(); } private void OKButton_Click(object sender, RoutedEventArgs e) { AddBookForm.CommitEdit(); this.DialogResult = true; } private void CancelButton_Click(object sender, RoutedEventArgs e) { newBook = null; AddBookForm.CancelEdit(); this.DialogResult = false; } } </code></pre> <p>Service.cs Page</p> <pre><code>public class OrganizationService : LinqToEntitiesDomainService&lt;LibraryEntities1&gt; { public IQueryable&lt;Book&gt; GetBooks() { return this.ObjectContext.Books.OrderBy(e =&gt; e.BookId); } public void InsertBook(Book book) { //book.Title = "Hello book"; //book.Author = "Ali"; //book.Category = "Humanity"; if ((book.EntityState != EntityState.Detached)) { this.ObjectContext.ObjectStateManager.ChangeObjectState(book, EntityState.Added); } else { this.ObjectContext.Books.AddObject(book); } } public void UpdateBook(Book currentBook) { this.ObjectContext.Books.AttachAsModified(currentBook, this.ChangeSet.GetOriginal(currentBook)); } public void DeleteBook(Book book) { if ((book.EntityState != EntityState.Detached)) { this.ObjectContext.ObjectStateManager.ChangeObjectState(book, EntityState.Deleted); } else { this.ObjectContext.Books.Attach(book); this.ObjectContext.Books.DeleteObject(book); } } } private void LibraryDataSource_SubmittedChanges(object sender, SubmittedChangesEventArgs e) { if (e.HasError) { MessageBox.Show(string.Format("Changes were not saved: {0}", e.Error.Message)); e.MarkErrorAsHandled(); } submitButton.IsEnabled = true; } void addBook_Closed(object sender, EventArgs e) { BookRegistaeration book = (BookRegistaeration)sender; if (book.newBook != null) { OrganizationContext _OrganizationContext = (OrganizationContext)(LibraryDataSource.DomainContext); _OrganizationContext.Books.Add(book.newBook); LibraryDataSource.SubmitChanges(); } } </code></pre>
    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.
    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