Alex
Alex

Reputation: 233

Show data according to condition sequence

I want to get it some filed using OrderBy condition but in my scenario orderby not working. In here my ProductSequence is int filed.

IList<ProViewModels> _newprd = iproRepository
  .GetList(x => x.ProductId.Equals(ProductId))
  .Select(x => new ProViewModels { ProductName = x.ProductName, DisplayName = x.DisplayName })
  .OrderBy(x => x.ProOrder)
  .ToList();

return _newprd;

Upvotes: 0

Views: 44

Answers (1)

anvil
anvil

Reputation: 36

From your repository you get a list of Products. Using Select you transform your list of Products to a list of ProViewModels. For your transformation you do not spezify the ProOrder property of ProViewModels, so the default value will be used.

Basically that means that your list gets ordered but the value they get ordered by is the same for all instances in the collection.

Upvotes: 1

Related Questions