Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 按名称订购货币代码_C#_Asp.net Mvc - Fatal编程技术网

C# 按名称订购货币代码

C# 按名称订购货币代码,c#,asp.net-mvc,C#,Asp.net Mvc,如何按姓名订购货币代码。在数据库中,我有Id和代码(名称),目前它们是按Id排序的。我想按名称ASC排序。 Down是我在ASP.NET中的C#代码 namespace Portal.Framework.Mvc.ViewDataPreparers { public class CurrenciesCodesPreparer : ActionFilterAttribute, IDataPreparer<Currency> { public IList<Curren

如何按姓名订购货币代码。在数据库中,我有Id和代码(名称),目前它们是按Id排序的。我想按名称ASC排序。 Down是我在ASP.NET中的C#代码

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");
    }
  }
}
namespace Portal.Framework.Mvc.ViewDataPreparers
{
公共类货币代码制备者:ActionFilterAttribute,IDataPreparer
{
公共IList GetDataItems()
{
返回DefaultContainerReference.Resolve().GetAllCurrences().CurrencyList;
}
公共静态字符串ViewDataKey{get{return“CurrenciesCodes”;}
公共覆盖无效OnActionExecuting(System.Web.Mvc.ActionExecutingContext筛选器上下文)
{
base.OnActionExecuting(filterContext);
filterContext.Controller.ViewData[ViewDataKey]=GetDataItems().ToSelectableList(true,Resources.Default_All,null,null,“Id”,“Code”);
}
}
}
这很简单

var currency = getallCurrency();
var sortByName = currency.OrderBy(x=>x.CurrenyName);
你可以这样做。

这很简单

var currency = getallCurrency();
var sortByName = currency.OrderBy(x=>x.CurrenyName);

您可以这样做。

您尝试过OrderBy吗?`return DefaultContainerReference.Resolve().GetAllCurrencies().CurrencyList.OrderBy(x=>x.Code)`您尝试过OrderBy吗?`return DefaultContainerReference.Resolve().GetAllCurrency().CurrencyList.OrderBy(x=>x.Code)`在这里您可以返回货币。你问我怎么能按名字点咖喱。。这意味着您已经返回了货币数据。只要把这个逻辑加在那里,你就可以把货币还给他。你问我怎么能按名字点咖喱。。这意味着您已经返回了货币数据。把这个逻辑加进去。