Exemplo n.º 1
0
        /// <summary>
        /// 获取专业数据
        /// </summary>
        /// <param name="sCode"></param>
        /// <param name="sName"></param>
        /// <param name="pageIndex"></param>
        /// <returns></returns>
        public ActionResult GetSpecialties(int sID)
        {
            ent.Configuration.LazyLoadingEnabled = false;

            //select* from  (select distinct(Specialty_ID) from SchoolClasses  where School_ID = 2)t left join Specialties on t.Specialty_ID = Specialties.Specialty_ID
            var result = from spyID in (
                from spy in ent.SchoolClasses
                where spy.School_ID == sID
                group spy by spy.Specialty_ID into spyID
                select new
            {
                Specialty_ID = spyID.Key
            })
                         join spe in ent.Specialties
                         on spyID.Specialty_ID equals spe.Specialty_ID
                         into Specialty
                         from Specialties in Specialty.DefaultIfEmpty()
                         select new
            {
                Specialty_ID          = Specialties.Specialty_ID,
                Specialty_Name        = Specialties.Specialty_Name,
                Specialty_Description = Specialties.Specialty_Description
            };

            return(Json(result, JsonRequestBehavior.AllowGet));
        }