c# - Change encoding of a list of objects -
i have program using dapper read in data sql server , save data mysql database. doing is:
- read in data sql server list of objects e.g.
list<akindofobject> =
read in data sql server - open connection mysql, save
list<akindofobject>
the problem property of akindofobject
saved chinese in original database. when data transferred mysql database, chinese characters shown "?".
is there way change encoding of list<akindofobject>
gb2312 in c# code?
i suspect happening here simply: database has non-unicode columns, , trying store unicode data. unrepresentable characters indeed greeked. correct fix there is: make sure column unicode. messing column encodings could work, damn that's lot of work compared using unicode.
dapper passes things "as is" ado.net; provider provider. there is way tell choose between ansi , unicode when sending data into database, though - via dbstring
, i.e.
conn.execute(sql, new { id, name, desc = new dbstring { isansi = true, value = desc } });
this allows control length etc. however, not controlling encoding here; encoding property of database itself, or of provider. if mysql has bespoke ways of controlling in ado.net, i'm "all ears", first: need working in raw ado.net.
Comments
Post a Comment