Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If I'm reading this correctly, the problem is expected via dbcontext or objectcontext.</p> <p>FIrst I want to look at your last set of examples ..no abstraction. When you attach a graph to a context, everything in the graph is attached as Unchanged. Period. The context doesn't care how you added or attached "children" to the root (e.g. siblings to a foo) before the context had ANY knowledge of them. If the foo was aalready known by the context and THEN you ADD, then the context is aware of HOW you did the linking..you said "ADD" so it marks them as Added and they'll get inserted.Even if the root is not new. You'ld have to change its state to "Unchanged". But in your case, you are taking a disconnected graph and attaching it, so everyting in the graph is seen as unchanged. You have to explicitly change the state of each of the siblings to what you want for SaveChanges to notice it needs to INSERT.</p> <p>Now to your repository. I have no idea wtf is up with the negative numbers. :) And I don't have time to experiment with that. (curious how that's tricking savechanges, but it's a smelly hack :) ) It depends on what's happening behind your FooRepository query. If that returned foo is beingi tracked by the context, then I would <em>expect</em> that when you ADD siblings, the context will know they are added and will create an insert. But if it is not being tracked, then when you ADD the siblings, context is not there to know about "ADD". At whatever point you reattach the graph (foo + its siblings) to a context, they are all going to be "UNchanged" so you're not getting the desired insert.</p> <p>This is all dependent on a GUESS at whatever else is going on in your repository and what, if any, affect the automapper has. I am guessing that you are doing all of the owrk before the context is aware of the graph so in the end , I think you're calling ATTACH which would result in no INSERTS being sent to the db.</p>
    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