EntityFramework更新或插入中文或非英文文本 [英] EntityFramework update or insert Chinese or non-English text

查看:236
本文介绍了EntityFramework更新或插入中文或非英文文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

实际上,在我没有使用框架或linq之前,只需使用Sqlcommand类输入sql语句,我键入 insert into table values(N'sample')
实际上我不知道什么是N,但它适用于中文和其他语言,否则会插入一些问号。



但是当我使用EntityFramework,这个一种框架总是插入一些问号,可以问问如何解决问题。



N表示Unicode?
你能给我一个EntityFramework使用这种东西的例子吗?

解决方案


  1. 在.edmx表中,选择列 - >检查其属性并将unicode设置为true

  2. 如果您在Code First Apporach中工作,则重新生成表

  3. 检查你的数据库表,它应该是nvarchar或ntext数据类型

这样EF将保存unicode字符。




Actually before i did not use framework or linq, just type in sql statement with Sqlcommand class, i type in insert into table values(N'sample') actually i donot know what is N, but it works for Chinese and other Language, otherwise, it will insert some question mark.

But when i use EntityFramework,this kind of framework always insert some question mark, can i ask how to tackle the issue.

N means Unicode? Can you give me one example that EntityFramework use that sort of thing?

解决方案

  1. in .edmx Table, select column -> check its properties and set unicode to true
  2. re-generate table if you are working in Code First Apporach
  3. check your database table, it should be nvarchar or ntext datatype

this way EF will save unicode characters.

这篇关于EntityFramework更新或插入中文或非英文文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆