如何使用linq到实体以UTF8编码读取字符串 [英] How to read a string with UTF8 coding using linq to entities
本文介绍了如何使用linq到实体以UTF8编码读取字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用Linq实体读取 LimeSurvey 表.我的问题是LimeSurvey将字符串存储在UTF8中,而.Net不喜欢它...
I am trying to read a LimeSurvey table using Linq to entities. My problem is that LimeSurvey stores strings in UTF8 and .Net doesn't like it...
因此,我有一个简单的函数可以列出所有调查,我如何告诉Linq读取UTF8格式的字符串?
So, i've got a simple function to list all my surveys, how can i tell Linq to read the strings in UTF8 format?
我的功能:
public static List<Lime_Surveys> List()
{
using (LimeSurveyEntities db = new LimeSurveyEntities())
{
IQueryable<Lime_Surveys> list = db.Lime_Surveys.Include("Lime_Surveys_LanguageSettings");
return list.ToList();
}
}
推荐答案
您需要更改使用
Encoding.UTF8.GetString(Encoding.Default.GetBytes(yourstring))
查看以下答案: 查看全文