Unexpected state of the updated entity

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for SQLite
Post Reply
AlexNek
Posts: 10
Joined: Wed 01 Jul 2015 19:12

Unexpected state of the updated entity

Post by AlexNek » Mon 27 Jul 2015 21:12

What I must looking for?
I have some similar tables connected with a grid over Binding source.
One form "suddenly" don't allow me to add new items.
System.InvalidOperationException occurred
HResult=-2146233079
Message=Unexpected state of the updated entity 'XxxDbContext.BaseName': e.
Source=Devart.Data.Linq
StackTrace:
at Devart.Data.Linq.Engine.SubmitCommandBuilder.b(IObjectEntry A_0, MetaType A_1, IEnumerable`1 A_2, Int32& A_3, Int32& A_4, Int32& A_5, StringBuilder A_6, List`1 A_7, List`1 A_8, AutoSyncMode& A_9)
at Devart.Data.Linq.Engine.SubmitCommandBuilder.a(IObjectEntry A_0)
at Devart.Data.Linq.Engine.b4.a(IObjectEntry[] A_0, ConflictMode A_1, a A_2)
at Devart.Data.Linq.Engine.b4.a(ConflictMode A_0)
at Devart.Data.Linq.DataContext.SubmitChanges(ConflictMode failureMode)
at xxx.BasesNameForm.buttonOk_Click(Object sender, EventArgs e) in xxx/BaseNameForm.cs:line 23
InnerException:

Code: Select all

public partial class BaseNameForm : Form
    {
        DataContext db;
        public BaseNameForm()
        {
            InitializeComponent();
        }

        private void BaseNameForm_Load(object sender, System.EventArgs e)
        {
            db = new DataContext();
            baseNameBindingSource.DataSource = db.BaseNames;
        }

        private void buttonOk_Click(object sender, System.EventArgs e)
        {
            db.SubmitChanges();//this is line 23
        }
    }
....
   [Table(Name = @"""main"".Base_name")]
    public partial class BaseName : INotifyPropertyChanging, INotifyPropertyChanged
    {

        private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(System.String.Empty);
        #pragma warning disable 0649

        private long _BaseNameId;

        private string _Name;

        private string _CustomName;
.....

MariiaI
Devart Team
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: Unexpected state of the updated entity

Post by MariiaI » Tue 28 Jul 2015 09:47

Please refer to http://forums.devart.com/viewtopic.php?f=31&t=26089.
If this information doesn't help, please prepare and send us a complete test project, with which this error could be reproduced. This will significantly speed up the process of determining the cause of the error and finding the solution for it.

AlexNek
Posts: 10
Joined: Wed 01 Jul 2015 19:12

Re: Unexpected state of the updated entity

Post by AlexNek » Tue 28 Jul 2015 23:22

I don't delete any objects before. I have a table with 10 records and try to add a new one over grid.
What I have found, that I can insert new record over source code but not over binding source and grid.
And absolute equal code works with the grid for an other table.
The problem with the sample that you can't compile it without the license for the grid. I'll try sample with the MS grid.

MariiaI
Devart Team
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: Unexpected state of the updated entity

Post by MariiaI » Wed 29 Jul 2015 09:33

Unfortunately, the information you have provided is not enough for reproducing this issue. Thus, we are waiting for your response with a complete test project (with the MS grid) or the test project, complete or by parts, with the grid you are using, so that we know the definitions of the DataContext class, entity classes, data binding, etc.

Also, LinqConnect offers the DbLinqDataSource component, that can perform deletes/updates/inserts automatically, without extending any methods. Do you use it? If not, please try using this functionality and inform us about the results. For more information please refer to http://www.devart.com/linqconnect/docs/ ... nding.html

AlexNek
Posts: 10
Joined: Wed 01 Jul 2015 19:12

Re: Unexpected state of the updated entity

Post by AlexNek » Wed 29 Jul 2015 16:24

thanks for the answer. I not try DbLinqDataSource now because up to one table all working fine. I'll try to create a sample.
But could you tell please what does it mean "Unexpected state of the updated entity" and when you throw it up?

MariiaI
Devart Team
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: Unexpected state of the updated entity

Post by MariiaI » Mon 03 Aug 2015 08:55

This error may occur for various reasons. Thus, the sample project would be helpful in order to find the reason of the error and the most suitable solution.

Post Reply