Created
February 1, 2016 23:48
-
-
Save vendettamit/fbb5a6bb88455744bc22 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
MyDbContext db = new MyDbContext(); | |
List<SelectListItem> selectedItems = new List<SelectListItem>(); | |
if (type == null) return selectedItems; | |
if (type == typeof(TestDemo)) | |
selectedItems = db.TestDemo.Select(i => new SelectListItem { Text = i.Name, Value = i.Id.ToString() }).ToList(); | |
if (type == typeof(TestDemo1)) | |
selectedItems = db.TestDemo1.Select(i => new SelectListItem { Text = i.Name, Value = i.Id.ToString() }).ToList(); | |
if (type == typeof(TestDemo2)) | |
selectedItems = db.TestDemo2.Select(i => new SelectListItem { Text = i.Name, Value = i.Id.ToString() }).ToList(); | |
if (type == typeof(TestDemo3)) | |
selectedItems = db.TestDemo3.Select(i => new SelectListItem { Text = i.Name, Value = i.Id.ToString() }).ToList(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment