OutOfSync Exception on Properties

Posts   
 
    
Lordns01
User
Posts: 1
Joined: 22-Mar-2013
# Posted on: 22-Mar-2013 16:13:57   

Hey everyone,

This has probably been addressed many times before through the forum but I had no such luck pinpointing my exact problem. Currently, I am to the point where I have generated the data access code and exercised it through a data access layer. I am able to create an entity and store it in the database (although it takes a little while 10-20 seconds per entity save). My issue is that when I take the entity and turn it back into a object, the properties that were on the entity are out of sync and cannot be accessed.

The code exercising the save and return: public IFormType AddFormType(string name, string desc, IFormType parent) { // check if it exists LinqMetaData metaData = new LinqMetaData(_dataAdapter); var entity = metaData.Formtype.FirstOrDefault(a => a.Name == name && a.Parentformtypeid == (parent == null ? -1 : GetDBType(parent).FormTypeID)); if (entity != null) { return EntityToObject(entity); }

        lock (LockObject)
        {
            long parentID = parent ==null?-1:GetDBType(parent).FormTypeID;

            FormtypeEntity fte = new FormtypeEntity
            {
                Name = name,
                Description = desc,
                Parentformtypeid = parentID
            };

            bool succesfulInsert = _dataAdapter.SaveEntity(fte, true);

            return EntityToObject(fte);
        }
    }

I have double checked my sequences and messed with the connection strings as far as timeout issues but have not found any solution. I am also having trouble accessing the source code for the SaveEntity() function so I can understand what exactly is going on. Any assistance would be much appreciated and thank you for your time.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 23-Mar-2013 06:22:12   

Please post more information, like LLBLGen version, runtime library version, exception message and stack trace (http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=7722).

Also, at this code:

long parentID = parent ==null?-1:GetDBType(parent).FormTypeID;

                FormtypeEntity fte = new FormtypeEntity
                {
                    Name = name,
                    Description = desc,
                    Parentformtypeid = parentID
                };

                bool succesfulInsert = _dataAdapter.SaveEntity(fte, true);

                return EntityToObject(fte);

... you are saving with Refetch=true, which is fine because the entity is refetched after save, so in theory you shouldn't receive the OutOfSync exception. But it could be the case that the entity is not saved because some reason. Is the entity actually saved on DB?

What is your DB? What is the PK of the entity? and Is it identity?

David Elizondo | LLBLGen Support Team