Linq没有与高棉unicode合作

时间:2012-03-30 02:51:24

标签: c# sql-server linq unicode linq-to-entities

我已经在C#.Net framework 4.0和sql server 2008中使用示例Application进行开发。当使用linq with method contains的查询不能与khmer unicode一起使用时。

注意:字段已经是NVARCHAR类型

结构表样本:

Person (id, name nvarchar(200))

Linq part :

var predicate = PredicateBuilder.True<Person>();

String strName = "ក";

predicate = predicate.And(e => e.Person.name.Contains(strName));

var query = Person.where(predicate);

return query.ToList();

结果所有记录以“ក”开头的名称不会显示在视图中。

你能帮我解决一下吗?


要用表格映射的模型类:

[Table(Name = "machine.PERSON")]
public class PersonModel : IEntity {
  [Column(Name = "id", DbType = "numeric(18,0) NOT NULL IDENTITY", IsPrimaryKey = true, IsDbGenerated = true)]
  public long Id { get; set; }
  [Column(Name = "name", DbType = "nvarchar(255) NULL")]
  public String Name { get; set; }
}

从db:

搜索值的样本linq代码
var predicate = PredicateBuilder.True<PersonModel>(); 
String strName = "ក";
predicate = predicate.And(p => p.Name.StartsWith(); 
var q = PersonModel.Where(predicate); 
var result = from P in q select new {P.Id, P.Name}; return result.ToList(); 

由linq传输的Sql语句:

SELECT [t0].[id] AS [Id], [t0].[name] AS [Name]
FROM [machine].[PERSON] AS [t0]
WHERE [t0].[name] LIKE @p0

0 个答案:

没有答案