什么是“WITH”的替代关键字在实体框架中? [英] What is alternative keyword for "WITH" in entity framework?

查看:67
本文介绍了什么是“WITH”的替代关键字在实体框架中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

;  WITH  MyCte(EType,EventDate,EName,EStatus) AS  

SELECT ' 考试' AS Expr1,E.DateOfExam,E.ExamName,tbl_ExamAttendence.status
FROM tbl_ExamCreation AS E INNER JOIN
tbl_ExamAttendence ON E.Exam_ID = tbl_ExamAttendence.Exam_ID
WHERE (tbl_ExamAttendence。 StudentID = 1044
UNION ALL
SELECT ' 讲座' AS Expr1,LS.StartDateTime,tbl_Lectures.LectureName,tbl_LectureAttendence.status
FROM tbl_LectureScheduling AS LS INNER JOIN
tbl_LectureAttendence ON LS.LectureScheduleID = tbl_LectureAttendence.LectureScheduleID INNER JOIN
tbl_Lectures ON LS.LectureID = tbl_Lectures.LectureID
WHERE (tbl_LectureAttendence.StudentID = 1044


SELECT TOP 5 EType,EventDate,EName,EStatus FROM MyCte ORDER BY EventDate DESC

解决方案

任何列出实体框架中SQL关键字的所有替代品的网站? [ ^ ]


 < span class =code-keyword> var  datas =( from  d  in  entityObj。 GetDataFunction  into  somename  select   new  {somename。 ID,Somename.Name ....}。取( 5 ); 





  public   class  Dto 
{
public int EType { get ; set ;}
public DateTime EventDate { get ; set ;}
public string EName { get ; < span class =code-keyword> set
;}
public string EStatus { get ; set ;
}

var myCte1 =(来自 m entityObj.tbl_ExamCreation join tb tbl_ExamAttendence ON E. Exam_ID = tb.Exam_ID 选择 new {EType = 考试,EventDate = m .DateOfExam,EName = m.ExamName,EStatus = tb.status})。选择(x => new Dto {EType = x.EType,EventDate = x.EventDate,EName = x.EName,EStatus = x.EStatus});





写同样的联盟之后的所有部分



你可以为这两个数据申请工会全部使用



  var  finalResult = myCte1.Concat(myCte2).Take( 5 ); 


;WITH MyCte(EType,EventDate,EName,EStatus) AS
(
SELECT     'Exam' AS Expr1, E.DateOfExam, E.ExamName,tbl_ExamAttendence.status
FROM         tbl_ExamCreation AS E INNER JOIN
                      tbl_ExamAttendence ON E.Exam_ID = tbl_ExamAttendence.Exam_ID
WHERE     (tbl_ExamAttendence.StudentID = 1044)
UNION ALL
SELECT     'Lecture' AS Expr1, LS.StartDateTime, tbl_Lectures.LectureName,tbl_LectureAttendence.status
FROM         tbl_LectureScheduling AS LS INNER JOIN
                      tbl_LectureAttendence ON LS.LectureScheduleID = tbl_LectureAttendence.LectureScheduleID INNER JOIN
                      tbl_Lectures ON LS.LectureID = tbl_Lectures.LectureID
WHERE     (tbl_LectureAttendence.StudentID = 1044)
)

SELECT TOP 5 EType,EventDate,EName,EStatus FROM MyCte ORDER BY EventDate DESC

解决方案

Any website which lists all the alternatives to the keyword of SQL in entity framework ?[^]


var datas=(from d in entityObj.GetDataFunction into somename select new{somename.ID,Somename.Name....}.Take(5);



public class Dto
{
public int EType{get;set;}
public DateTime EventDate{get;set;}
public string EName{get;set;}
public string EStatus{get;set;
}

var myCte1=(from m in entityObj.tbl_ExamCreation join tb in tbl_ExamAttendence ON E.Exam_ID = tb.Exam_ID select new{ EType="Exam",EventDate=m .DateOfExam, EName=m.ExamName,EStatus=tb.status}).Select(x=>new Dto{EType=x.EType,EventDate=x.EventDate,EName=x.EName,EStatus=x.EStatus});



write same for part after Union all

and you can apply union all for these two data and take Top 5 using

var finalResult= myCte1.Concat(myCte2).Take(5);


这篇关于什么是“WITH”的替代关键字在实体框架中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆