Problems upgrading to new version

Posts   
 
    
hplloyd
User
Posts: 191
Joined: 29-Oct-2004
# Posted on: 06-Jun-2005 11:30:23   

I have an application that has been developed under version 1.02004.1 and I am trying to upgrade it to work with 1.02004.2

I first regenerated all the code, including the very basic manager classes that I had put together for this application and teh recompiled the solution.... 0 errors GREAT

However when I run the application it works fine until it gets to a piece of code that tries to retrive an entity from its primary Key...

I get the error - The field EmployeeID is read-only and can't be changed

which is fine because EmployeeID is the primary key and so therefore should be read only.

My issue is that the code causing this error is:

DataAccessAdapter LLBLAdapter = new DataAccessAdapter(...) mEntity = new EmployeeEntity(intID) LLBLAdapter.FetchEntity(mEntity)

It is the middle line that causes the error - intID is the PrimaryKeyID of the Employee I want to return. But I dont see why this code is trying to change the value of the field.

What am I doing wrong?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 06-Jun-2005 12:51:18   

The exception is thrown when the field set is readonly and not part of the PK. I.o.w.: if it's part of the PK it won't give you that exception. In the constructor the code this.ID = intID is done, which throws the exception apparently.

Simple test:


[Test]
public void PkFetchTest()
{
    using(DataAccessAdapter adapter = new DataAccessAdapter())
    {
        OrderEntity o = new OrderEntity(10254);
        Assert.IsTrue(adapter.FetchEntity(o));
    }
}

Order is a northwind order, which has an identity pk field, orderid, which is therefore readonly and also the PK.

In EntityFieldFactory.cs, the field OrderID is indeed marked readonly and also part of the PK. Could you please check if that's also the case for your field? The routine should use the first EntityField2 constructor (with the most parameters). It could be the file wasn't overwritten during code generation?

Frans Bouma | Lead developer LLBLGen Pro
hplloyd
User
Posts: 191
Joined: 29-Oct-2004
# Posted on: 06-Jun-2005 15:28:00   

Yup,

In LLBL the field was marked as read only but NOT as the primary key...Once I refreshed the catalogs and then generated the code everything works perfectly.

I didnt think I needed to refresh the catalog to upgrade - that was my mistake, sorry.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 06-Jun-2005 15:59:52   

hplloyd wrote:

Yup,

In LLBL the field was marked as read only but NOT as the primary key...Once I refreshed the catalogs and then generated the code everything works perfectly.

I didnt think I needed to refresh the catalog to upgrade - that was my mistake, sorry.

You don't have to by default, but if the field isn't marked as PK you now see that it's not. simple_smile Glad it's solved simple_smile

Frans Bouma | Lead developer LLBLGen Pro