How to remove “diffgr:before” content from returne

2019-02-21 17:44发布

问题:

I have a web method:

public DataSet SyncedWall()
    {
            DataSet dst = dscomment;
            dst.Tables[0].Rows[i]["WallInfo"] = "my own modified value";
            return dst;
    }

Although the real method is big but this is a minified version.

Following is the xml output received from the web method:

<DataSet>
<xs:schema id="NewDataSet">
<!-- Schema goes here.. -->
</xs:schema>

<diffgr:diffgram>

<NewDataSet>
<!-- Dataset values goes here... -->
</NewDataSet>

<diffgr:before>
<!-- Here are the original modified (unwanted) values -->
</diffgr:before>
</diffgr:diffgram>
</DataSet>

What I want is to remove the <diffgr:before> tag and its inner contents. How to do that?

回答1:

Hurreeyyyyyy!!!

I've found the answer after scratching my head upto couples of hours. :P Before returning the dataset just call for datasetObject.AcceptChanges(); and you're done.

So here is the code:

public DataSet SyncedWall()
    {
            DataSet dst = dscomment;
            dst.Tables[0].Rows[i]["WallInfo"] = "my own modified value";
            dst.AcceptChanges();
            return dst;
    }