Click here to Skip to main content
13,409,651 members (41,530 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Hi all,

i am using entity framework to access the Db in my project

here i want to update two entity(table) by clicking a update button

Dim xx As entityname = objContext.entityname.Where(Function(c) c.Rowid = intRowId And c.Type = intType).SingleOrDefault
If (true) Then
If Not IsNothing(xx) Then
xx.intrr = xx.intrr + intss
xx.intaa = xx.intaa - intpp
End If

Dim yy As entityname1 = objContext.entityname1.Where(Function(d) d.Rowid = intRowId And d.Type = intType).SingleOrDefault

If Not IsNothing(yy) Then
yy.intxx = yy.xx + intyy
yy.inttt = yy.inttt - intss
End If

End If

the above denoting to update two entity in same functionality

here i can able to update the entityname entity
and i also can able to update the entityname 1 entity
but i cannot able to update only one field in entityname1 (for example yy.inttt)

so that i saw the design of the table in the SQL, to check the default binding values
since there is no anyvalue to bind default

what is the mistake done by me
please let me know
Posted 15-Feb-12 2:10am
Updated 15-Feb-12 9:13am
Mark Nischalke 15-Feb-12 11:26am
It isn't very clear. Do you only want the field yy.inttt to be updated, and no other field on this entity?
msk kumar 16-Feb-12 1:54am
Hi Mark
I need to update two entities(tables), enatityname and entityname1 also
in entityname entity
xx.intrr = xx.intrr + intss
xx.intaa = xx.intaa - intpp
this want to update

in entityname1 entity also want to update the following two fields
yy.intxx = yy.xx + intyy
yy.inttt = yy.inttt - intss
Here the field yy.inttt is only not updating (stay remains the same value in the DB)
but yy.inttxx is updating fine

i think it is clear now
thank you
Kreagan Naicker 15-Feb-12 14:18pm
I'm with Mark on this one, i'm not sure what you require assistance with.

If i literally translation your request, then you only what to update the variable yy.inttt, if this is the case then simply remove the following statement:
yy.intxx = yy.xx + intyy

This should result in only the yy.inttt variable being updated.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

If you want to update the entire object graph then ApplyCurrentValues is not necessary.[^]
"The ApplyCurrentValues(Of TEntity) method is used to apply changes that were made to objects outside the ObjectContext, such as detached objects that are received by a Web service."

You don't have a detached object.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03 | 2.8.180221.1 | Last Updated 16 Feb 2012
Copyright © CodeProject, 1999-2018
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100