mgholam / fastJSON

Smallest, fastest polymorphic JSON serializer
https://www.codeproject.com/Articles/159450/fastJSON-Smallest-Fastest-Polymorphic-JSON-Seriali
MIT License
479 stars 147 forks source link

Serialize DataTable with Deleted rows #122

Closed wahmedswl closed 3 years ago

wahmedswl commented 3 years ago

Hi, Getting following exception when trying to serialize DataTable with deleted rows.

System.Data.DeletedRowInaccessibleException
  HResult=0x80131921
  Message=Deleted row information cannot be accessed through the row.
  Source=System.Data
  StackTrace:
   at System.Data.DataRow.GetDefaultRecord()
   at fastJSON.JSONSerializer.WriteDataTableData(DataTable table)
   at fastJSON.JSONSerializer.WriteDataset(DataSet ds)
   at fastJSON.JSONSerializer.WriteValue(Object obj)
   at fastJSON.JSONSerializer.ConvertToJSON(Object obj)
   at Playground.Playground.Main(String[] args) in C:\Gitlab\Core\CSharp\Playground.cs:line 187

  This exception was originally thrown at this call stack:
    System.Data.DataRow.GetDefaultRecord()
    fastJSON.JSONSerializer.WriteDataTableData(System.Data.DataTable)
    fastJSON.JSONSerializer.WriteDataset(System.Data.DataSet)
    fastJSON.JSONSerializer.WriteValue(object)
    fastJSON.JSONSerializer.ConvertToJSON(object)
    Playground.Playground.Main(string[]) in Playground.cs

Thanks

mgholam commented 3 years ago

Try running dataset.AcceptChanges(); before serializing.

wahmedswl commented 3 years ago

That i get but then everything is lost. Diffgram support so that changes can be sent over wire eg: RPC etc

Thanks

mgholam commented 3 years ago

Ah, I see so you want to send the "edited" client side dataset to the server for processing?

wahmedswl commented 3 years ago

Yes, this is the primary reason as currently Xml is the only option.

mgholam commented 3 years ago

Personally I would handle it outside of fastJSON, see this https://weblogs.asp.net/aaguiar/27459 and send the "deleted" "edited" "added" separately.

wahmedswl commented 3 years ago

Its not to send it to client, its to send via RPC, Server to Server. Also, in this way this needs to be implemented by Every client, rather than built-in support in the Library.

Thanks