Conditional mapping using GraphDiff












0















I am having an issue with GraphDiff whilst saving some data and I just need some one to confirm if this is possible.



I will provide an example of what is going on:



Firstly, I am using VS2017 (latest revision) EF 6, Automapper and GraphDiff.



I have a table which contains the following data.



Table Data



As you can see this lists data for a ParcelId of 5023, the only difference is the IsAcquired and IsCurrent flags.



I am not going into the code that updates the data with the IsCurrent flag set to true as it is very complicated, but in essence, a screen allows users to enter values, that on saving sets the records in the second list from IsCurrent to False and inserts Three new records that have new values and has the IsCurrent set to True. This provides us the ability to undo these records.



Now, I have differnt screen that enables you to edit the main data, or in other words the data from the first grid.



This is using GrphDiff to update the data. The data that is in the second grid is NOT recovered for this edit, but on saving the GraphDiff opertaion is seeing that the data is different and overwriting in.



dbContext.UpdateGraph(a,map=>map.OwnedCollection(x => x.ParcelRight);


I need it to ingnore the records that an IsCurrent equals true and only update records that have IsAcquired = true.



I tried:



dbContext.UpdateGraph(a,map=>map.OwnedCollection(x => x.ParcelRight
.Where(r => r.IsAcquired == true).ToList());


but it did not work.



I found the following which sort of implies that it cannot be done.



Research










share|improve this question



























    0















    I am having an issue with GraphDiff whilst saving some data and I just need some one to confirm if this is possible.



    I will provide an example of what is going on:



    Firstly, I am using VS2017 (latest revision) EF 6, Automapper and GraphDiff.



    I have a table which contains the following data.



    Table Data



    As you can see this lists data for a ParcelId of 5023, the only difference is the IsAcquired and IsCurrent flags.



    I am not going into the code that updates the data with the IsCurrent flag set to true as it is very complicated, but in essence, a screen allows users to enter values, that on saving sets the records in the second list from IsCurrent to False and inserts Three new records that have new values and has the IsCurrent set to True. This provides us the ability to undo these records.



    Now, I have differnt screen that enables you to edit the main data, or in other words the data from the first grid.



    This is using GrphDiff to update the data. The data that is in the second grid is NOT recovered for this edit, but on saving the GraphDiff opertaion is seeing that the data is different and overwriting in.



    dbContext.UpdateGraph(a,map=>map.OwnedCollection(x => x.ParcelRight);


    I need it to ingnore the records that an IsCurrent equals true and only update records that have IsAcquired = true.



    I tried:



    dbContext.UpdateGraph(a,map=>map.OwnedCollection(x => x.ParcelRight
    .Where(r => r.IsAcquired == true).ToList());


    but it did not work.



    I found the following which sort of implies that it cannot be done.



    Research










    share|improve this question

























      0












      0








      0








      I am having an issue with GraphDiff whilst saving some data and I just need some one to confirm if this is possible.



      I will provide an example of what is going on:



      Firstly, I am using VS2017 (latest revision) EF 6, Automapper and GraphDiff.



      I have a table which contains the following data.



      Table Data



      As you can see this lists data for a ParcelId of 5023, the only difference is the IsAcquired and IsCurrent flags.



      I am not going into the code that updates the data with the IsCurrent flag set to true as it is very complicated, but in essence, a screen allows users to enter values, that on saving sets the records in the second list from IsCurrent to False and inserts Three new records that have new values and has the IsCurrent set to True. This provides us the ability to undo these records.



      Now, I have differnt screen that enables you to edit the main data, or in other words the data from the first grid.



      This is using GrphDiff to update the data. The data that is in the second grid is NOT recovered for this edit, but on saving the GraphDiff opertaion is seeing that the data is different and overwriting in.



      dbContext.UpdateGraph(a,map=>map.OwnedCollection(x => x.ParcelRight);


      I need it to ingnore the records that an IsCurrent equals true and only update records that have IsAcquired = true.



      I tried:



      dbContext.UpdateGraph(a,map=>map.OwnedCollection(x => x.ParcelRight
      .Where(r => r.IsAcquired == true).ToList());


      but it did not work.



      I found the following which sort of implies that it cannot be done.



      Research










      share|improve this question














      I am having an issue with GraphDiff whilst saving some data and I just need some one to confirm if this is possible.



      I will provide an example of what is going on:



      Firstly, I am using VS2017 (latest revision) EF 6, Automapper and GraphDiff.



      I have a table which contains the following data.



      Table Data



      As you can see this lists data for a ParcelId of 5023, the only difference is the IsAcquired and IsCurrent flags.



      I am not going into the code that updates the data with the IsCurrent flag set to true as it is very complicated, but in essence, a screen allows users to enter values, that on saving sets the records in the second list from IsCurrent to False and inserts Three new records that have new values and has the IsCurrent set to True. This provides us the ability to undo these records.



      Now, I have differnt screen that enables you to edit the main data, or in other words the data from the first grid.



      This is using GrphDiff to update the data. The data that is in the second grid is NOT recovered for this edit, but on saving the GraphDiff opertaion is seeing that the data is different and overwriting in.



      dbContext.UpdateGraph(a,map=>map.OwnedCollection(x => x.ParcelRight);


      I need it to ingnore the records that an IsCurrent equals true and only update records that have IsAcquired = true.



      I tried:



      dbContext.UpdateGraph(a,map=>map.OwnedCollection(x => x.ParcelRight
      .Where(r => r.IsAcquired == true).ToList());


      but it did not work.



      I found the following which sort of implies that it cannot be done.



      Research







      c# entity-framework automapper graphdiff






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 14 '18 at 14:22









      gilesrpagilesrpa

      370317




      370317
























          1 Answer
          1






          active

          oldest

          votes


















          0














          Thanks to all that looked at this, but it looks like it is something that causes GraphDiff issues, so I have changed my code for this update to use a more traditional Linq to Entites solution.






          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53302406%2fconditional-mapping-using-graphdiff%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            Thanks to all that looked at this, but it looks like it is something that causes GraphDiff issues, so I have changed my code for this update to use a more traditional Linq to Entites solution.






            share|improve this answer




























              0














              Thanks to all that looked at this, but it looks like it is something that causes GraphDiff issues, so I have changed my code for this update to use a more traditional Linq to Entites solution.






              share|improve this answer


























                0












                0








                0







                Thanks to all that looked at this, but it looks like it is something that causes GraphDiff issues, so I have changed my code for this update to use a more traditional Linq to Entites solution.






                share|improve this answer













                Thanks to all that looked at this, but it looks like it is something that causes GraphDiff issues, so I have changed my code for this update to use a more traditional Linq to Entites solution.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 16 '18 at 8:40









                gilesrpagilesrpa

                370317




                370317
































                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53302406%2fconditional-mapping-using-graphdiff%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    List item for chat from Array inside array React Native

                    Thiostrepton

                    Caerphilly