我想使用Asp.net MVC和實體框架存儲和排序Unicode字符。那麼做到這一點的最好方法是什麼? 我箱子模型,學生模型:如何存儲和排序Unicode字符
public class Student
{
public int ID { get; set; }
public string LastName { get; set; }
public string FirstMidName { get; set; }
public DateTime EnrollmentDate { get; set; }
}
在StudentController在索引操作:
public ActionResult Index(string sortOrder)
{
ViewBag.NameSortParm = String.IsNullOrEmpty(sortOrder) ? "name_desc" : "";
ViewBag.DateSortParm = sortOrder == "Date" ? "date_desc" : "Date";
var students = from s in db.Students
select s;
switch (sortOrder)
{
case "name_desc":
students = students.OrderByDescending(s => s.LastName);
break;
case "Date":
students = students.OrderBy(s => s.EnrollmentDate);
break;
case "date_desc":
students = students.OrderByDescending(s => s.EnrollmentDate);
break;
default:
students = students.OrderBy(s => s.LastName);
break;
}
return View(students.ToList());
}
我用 「students = students.OrderByDescending(s => s.LastName);
」 進行排序學生姓名。它適用於英文,但不起作用Unicode,如高棉字符
你嘗試過什麼這麼發R'對Unicode的支持通常內置於.NET和(ASP.NET MVC中),你有什麼困難? –
我使用「students = students.OrderByDescending(s => s.LastName);」分類學生姓名。它適用於英文,但不能像高棉字符那樣工作。 – user3555183
編輯問題通常比在評論中添加相關信息更好。所以,告訴我們'學生'包含什麼,結果是什麼,以及你的期望。如果你想快速而且很好的回答,花點時間寫下一個好問題是非常值得的:https://msmvps.com/blogs/jon_skeet/archive/2010/08/29/writing-the-perfect-question.aspx –