Thursday 15 May 2014

entity framework - EF 4.1 Issue retrieving original and current values -


I am using EF 4.1 and sluggish loading. I have institutions:

  Public intangible class personality {{key (required) [database-generated (database-generated operation identity)] Public Ent ID {Received; Set; } .... [foreign ("quantity")] public virtual int? Quantity ID {Receive; Set; } Receive public virtual volume quantity; Set; }}} Public class ConcretePerson: Personbase {....} Public Sector Amount {{Key (), Required] [Database Generated (Database Generated Operation Identification)] Public Ent ID {Received; Set; } [Required] Public Virtual Float Quantity A {get; Set; } [Required] Public Virtual Float QuantityB {get; Set; } [Required] Public virtual float volume C {get; Set; }} IDbset & lt; Quantity & gt; Quantity; IDbSet & LT; ConcretePerson & gt; ConcretePersons; IDbSet & LT; PersonBase & gt; Individuals;   

Then in my code I do the following:

 using  (DataBaseContext Reference = New Database Consort ()) {IQueryable & lt; ConcretePerson & gt; ConcretePersonClippen = References Contractpers Where (& lt; condition & gt;); Leading (ConcretePerson ConcretePerson ConcretePersonConption) {... ConcretePerson. QuantityA = new_quantity_A; ConcretePerson. Quantity QuantityB = new_quantity_B; ConcretePerson. quantity. Quantity c = new_contacteac; ...} ... DbEntityEntry & lt; ConcretePerson & gt; EntityEntry; Volume quantity; Forchha (ConcretePerson ConcretePerson in ConcretePersonConclusion) {Entity Entry = Reference. Entry & LT; Concrete Mason & gt; (Conneperson); If (unit entry.state == system.data.intstate.detailed) {quantity = ((ConcretePerson) unit entry current value.Two object ()). Quantity; } And {quantity = solid display. Quantity; } ...} ... context.SaveChanges (); }   


Note that I only execute SaveChanges, until this point the database is not updated.

I have problems within the foreign exchange: - 1. When the entry of the unit. This happens if the state is modified (ConcretePerson) Entity Entry. Current Value. Two Object ()). The quantity is zero, but ((ConcretePerson) unit Entry.CurrentValues.ToObject ()). QuantityId is true right) Why? How to get it different from existing values ​​(neither the base values ​​nor the database value), only in existing values?

2.- If I check the quantity directly by displaying concrete. It is not zero, but the concrete provider. Amount included in the current value (previously updated in Forex), not the original (value before updating in the first foreign currency). Should not be concrete instead of the person. Quantity origin values ​​(prior to updating in foreach)? Because I have not made any reference between two foreach loops.
3.-Reference. Changes made to the Save Changes database are not saved and no errors are taking place. & Lt; ---- This point has been solved, I was pointing to a different reference, no one was using it (now I am using it).

  1. There is a strange way to try to get this value ... Do it

  2. ConcretePerson. Become a copy of the volume unit, so that whatever value it has been given will be.

    In the first foreign currency you are actually modifying each item in the collection (even if it is not saved in database, still it is still in memory , Otherwise how does AF know how to save the database?). In the second you are actually investigating the same collection whether institutions have been modified (which they have) and then get the present value. Although the current value for the quantity will be the same when you have revised the unit. If you check the original value for the modified entries, you will see that it is different.

    Basically the value of the current value memory unit (if you change the current CurrentValue property). OriginalValue

    1. Nevermind; P

No comments:

Post a Comment