コード例 #1
0
        public static SelectList SelectListTopic(int id = 0, string langId = "")
        {
            var list = new List <Topic>();

            if (langId == "")
            {
                list = new MyBlogEntities().Topics.ToList();
                list.Add(new Topic()
                {
                    Id = 0, Name = "Not exists"
                });
            }
            else
            {
                list = new MyBlogEntities().Topics.Where(x => x.LangId == langId).ToList();
            }
            return(new SelectList(list, "Id", "Name", id));
        }