Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Thanks to @sgmoore . The values to be updated are set after the Attach method. Now it is working. Is there anything yet to improve?</p> <p>Generated SQL</p> <pre><code>UPDATE [dbo].[Account] SET [AccountType] = @p2, [Duration] = @p3, [ModifiedTime] = @p4 WHERE ([AccountNumber] = @p0) AND ([ModifiedTime] = @p1) -- @p0: Input Int (Size = -1; Prec = 0; Scale = 0) [1] -- @p1: Input DateTime (Size = -1; Prec = 0; Scale = 0) [6/25/2012 5:08:32 PM] -- @p2: Input NChar (Size = 10; Prec = 0; Scale = 0) [NEXT] -- @p3: Input Int (Size = -1; Prec = 0; Scale = 0) [4] -- @p4: Input DateTime (Size = -1; Prec = 0; Scale = 0) [6/26/2012 10:29:19 AM] -- Context: SqlProvider(Sql2008) Model: AttributedMetaModel Build: 4.0.30319.1 </code></pre> <p>CODE</p> <pre><code> public void UpdateAccount() { //Used value from previous select DateTime previousDateTime = new DateTime(2012, 6, 25, 17, 8, 32, 677); RepositoryLayer.Account accEntity = new RepositoryLayer.Account(); accEntity.AccountNumber = 1; //Primary Key accEntity.ModifiedTime = previousDateTime; //Concurrency column accountRepository.UpdateChangesByAttach(accEntity); //Values to be modified after Attach accEntity.AccountType = "NEXT"; accEntity.ModifiedTime = DateTime.Now; accEntity.Duration = 4; accountRepository.SubmitChanges(); } public virtual void UpdateChangesByAttach(T entity) { if (Context.GetTable&lt;T&gt;().GetOriginalEntityState(entity) == null) { //If it is not already attached Context.GetTable&lt;T&gt;().Attach(entity); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload