Download the object twice and change one of them, the other will not change

Father father = BL.GetFatherById(1);  
Product product = BL.GetByID(123);  

(father.Products[553] == product)  

product.delete = true;  

father.Products[553].delete == false !!??   

why?

are they connected? its one and the same object.

+3
source share
2 answers

As you can read in Section 10.3 of the NHibernate Reference Guide, database identification and CLR object identifier are equivalent per session.

Therefore, it Object.ReferenceEquals(foo, bar)will give trueif and only if fooboth are bartied to one session and are mapped to the same database row. Be careful when using the ==object identifier for comparison - the operator may have been overloaded (but you usually know this).

, , . ? , " ", , ?

+3

-, , , , .

father.Products[553] == product;

, , , .

  • , 553 ?
  • 553?
  • ?
  • ?

,

  • IEnumerable,
  • , .

, ( )

? HasOne x

+1

Source: https://habr.com/ru/post/1749793/


All Articles