本文介绍了按名称订单货币codeS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我怎么可以为了我的货币codeS的名字。在数据的基础上,我有身份证和code(名称),目前他们被编号为顺序。我想通过名称ASC进行排序。
羽绒是在ASP.NET我的C#code
命名空间Portal.Framework.Mvc.ViewData preparers
{
公共类货币codeS preparer:ActionFilterAttribute,IData的preparer<货币和GT;
{
公众的IList<货币和GT; GetDataItems()
{
返回DefaultContainerReference.Resolve< IGlobalizationService方式>()GetAllCurrencies()CurrencyList。
} 公共静态字符串ViewDataKey {{返回的C $ CS货币$; }} 公共覆盖无效OnActionExecuting(System.Web.Mvc.ActionExecutingContext filterContext)
{
base.OnActionExecuting(filterContext);
filterContext.Controller.ViewData [ViewDataKey] = GetDataItems()ToSelectableList(真,Resources.Default_All,NULL,NULL,ID,code)。
}
}
}
解决方案
据退出简单。
VAR货币= getallCurrency();
VAR sortByName = currency.OrderBy(X => x.CurrenyName);
你可以做到这样。
how can i order my currency codes by name. In data base i have Id and Code(name),and currently they are order by Id. I want to order them by name ASC.Down is my C# code in ASP.NET
namespace Portal.Framework.Mvc.ViewDataPreparers
{
public class CurrenciesCodesPreparer : ActionFilterAttribute, IDataPreparer<Currency>
{
public IList<Currency> GetDataItems()
{
return DefaultContainerReference.Resolve<IGlobalizationService>().GetAllCurrencies().CurrencyList;
}
public static string ViewDataKey { get { return "CurrenciesCodes"; } }
public override void OnActionExecuting(System.Web.Mvc.ActionExecutingContext filterContext)
{
base.OnActionExecuting(filterContext);
filterContext.Controller.ViewData[ViewDataKey] = GetDataItems().ToSelectableList(true, Resources.Default_All, null, null, "Id", "Code");
}
}
}
解决方案
It is quit simple.
var currency = getallCurrency();
var sortByName = currency.OrderBy(x=>x.CurrenyName);
you can do like this.
这篇关于按名称订单货币codeS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!