Error System.Collections.Generic.List`1[Accountstatement.Models.MenuModel]

i try to get list from table, i code this on controller

var _menu = new List<MenuModel>();
                if (con.State == ConnectionState.Closed)
                string query = "";
                var role = Session["sessionrole"];

                query = "SELECT * FROM \"SubMenu\" INNER JOIN \"Main_menu\" ON \"SubMenu\".\"MainMenuId\" = \"Main_menu\".\"Id\"  WHERE \"ROLE_ID\" = @role";

                NpgsqlCommand cmd = new NpgsqlCommand(query, con);

                var reader = cmd.ExecuteReader();
                while (reader.Read())
                    _menu.Add(item: new MenuModel
                        MainMenuName = reader["MainMenu"] != DBNull.Value ? (string)reader["MainMenu"] : ""


            catch (Exception ex)


            Session["Menu"] = _menu;

i try to render Session["Menu"] in view index and i dont see my list rendered instead i got System.Collections.Generic.List`1[Accountstatement.Models.MenuModel], i tried to render Session["Menu"].ToString in view and have same result any recomendation?

Read more here:

Content Attribution

This content was originally published by Romli Eko at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: