Last active
August 17, 2017 12:32
-
-
Save HamidMosalla/b6a345f1467219bd2a900f4222754b33 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public List<SelectListItem> GetStockSelectListItemsWithOptionGroup(Company[] companies, Stock[] stocks) | |
{ | |
var optionGroups = companies.GroupBy(c => c.CompanyId, c => c.CompanyName).Select(c => new SelectListGroup { Name = c.First() }); | |
return stocks.Select(s => new SelectListItem | |
{ | |
Text = s.StockName, | |
Value = s.StockId.ToString(), | |
Group = optionGroups.Single(o => o.Name.Trim() == s.CompanyName.Trim()) | |
}).ToList(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment