c# - Change encoding of a list of objects -


i have program using dapper read in data sql server , save data mysql database. doing is:

  1. read in data sql server list of objects e.g. list<akindofobject> = read in data sql server
  2. 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

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -