c# - Value was either too large or too small for a UInt64 while deserializing data -
i posting json string method , getting error while deserializing class.
error:
error converting value -1 type 'system.nullable`1[system.uint64]'. path 'mymappings1.mysqlcolumns[7].size'. inner exception : {"value either large or small uint64."}
below class in want output after deserializing json value :
public class mymappings { public string name { get; set; } public list<mysqlcolumns> mysqlcolumns { get; set; } } public class mysqlcolumns { public string column { get; set; } public string datatype { get; set; } public string isnullable { get; set; } public uint64? size { get; set; } public uint64? numericprecision { get; set; } public uint64? numericscale { get; set; } } string myjson = "mymappings": [ { "name": "dbo.table1", "mysqlcolumns": [ { "name": "address", "datatype": "nvarchar", "isnullable": "yes", "size": -1, "numericprecision": null, "numericscale": null }] var deserializedata = jsonconvert.deserializeobject<mymappings>(myjson);
now when user set nvarchar(max) columns set size -1 setinel value represent max size.now reason setting size -1 because while reading column size nvarchar(max) setinel value -1 per marc gravell comment
i have seen answer question how use while deserialization.i using newtonsoft json
update:reason specifying size uint:
can please me this??
the u
in types names stands unsigned values positive. value -1 small stored in such variable. either change type signed int64
. or use null
marker max , interpret accordingly while creating column.
as update thing can use null , make logic interpret -1 when needed. sad can't have cake , eat @ same time.
Comments
Post a Comment