Entity Cache

Posts   
 
    
chungpn
User
Posts: 39
Joined: 23-Mar-2011
# Posted on: 26-Jul-2011 05:18:42   

I use this code to fetch an entity private void button3_Click(object sender, EventArgs e) {

        te.Test = Decimal.Parse(textBox1.Text);
        pictureBox1.Image = null;
        da.FetchEntity(te);

        this.pictureBox1.Image  = te.Test4;

    }

where te is an Form entity variable TblTestEntity te=new TblTestEntity();

the problem is when I change the PK key (input in textbox1) then submit, but the the te entity not refresh.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 26-Jul-2011 09:04:01   

I don't understand you.

Generally if you want to fetch an existing entity, you should pass the PK value to the constructor of the entity.

chungpn
User
Posts: 39
Joined: 23-Mar-2011
# Posted on: 26-Jul-2011 10:26:21   

this code also fetch entity base on the value in textbox1.text

    DataAccessAdapter da = new DataAccessAdapter();
    private TblTestEntity te;

private void button3_Click(object sender, EventArgs e) {

        te = new TblTestEntity();
        te.Test = Decimal.Parse(textBox1.Text);

        da.FetchEntity(te);


        this.pictureBox1.Image  = te.Test4;

    }

but when I put te = new TblTestEntity(); outside the button3_Click event, it only load the entity base on the textbox.text value for the fisrt time. It mean, if I input another value to textBox1.text and click again, its remain the value of the entity.

Thank you.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 26-Jul-2011 11:07:40   

Which runtime library version (build no.) are you using? Please note that the PK should not be changed for an existing entity.

That's why you need to re-instantiate the entity to set the PK, agian.

chungpn
User
Posts: 39
Joined: 23-Mar-2011
# Posted on: 26-Jul-2011 11:09:53   

yes, i see I use llblgen 3.1