protected void Page_Load(object sender, EventArgs e)
        {
            context = new AdventureWorks2014Entities();


            // var query = context.Departments.Select((x) => x.Name);
            // var json=Newtonsoft.Json.JsonConvert.SerializeObject(query.ToList());

            var temp   = Request.QueryString["group"];
            var query2 = from departments in context.Departments
                         where departments.GroupName == temp
                         select new
            {
                departments.DepartmentID,
                departments.Name,
                departments.GroupName,
                departments.ModifiedDate
            };
            var json = Newtonsoft.Json.JsonConvert.SerializeObject(query2.ToList());

            Response.Clear();
            Response.ContentType = "application/json; charset=utf-8";
            Response.Write(json);
            Response.End();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            context = new AdventureWorks2014Entities();


            var query = context.Departments.Select((x) => x.GroupName).Distinct();
            var json  = Newtonsoft.Json.JsonConvert.SerializeObject(query.ToList());

            Response.Clear();
            Response.ContentType = "application/json; charset=utf-8";
            Response.Write(json);
            Response.End();
        }
Esempio n. 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            context = new AdventureWorks2014Entities();
            var query = from departments in context.Departments
                        select departments;

            GridView1.DataSource = query.ToList();
            GridView1.DataBind();

            var query2 = context.Departments.Select(group => group.GroupName).Distinct();

            DropDownList1.DataSource = query2.ToList();
            DropDownList1.DataBind();
        }
Esempio n. 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            context = new AdventureWorks2014Entities();
            XElement element = new XElement("Departments",
                                            (from departments in context.Departments
                                             select new
            {
                departments.DepartmentID,
                departments.Name,
                departments.GroupName,
                departments.ModifiedDate
            }).ToList().Select(x =>
                               new XElement("Department", new XElement("DepartmentID", x.DepartmentID),
                                            new XElement("Name", x.Name),
                                            new XElement("GroupName", x.GroupName),
                                            new XElement("ModifiedDate", x.ModifiedDate)
                                            )));

            Response.Clear();
            Response.ContentType = "application/xml; charset=utf-8";
            Response.Write(element);
            Response.End();
        }