首页 新闻 会员 周边 捐助

这句sql如何翻译成linq?

0
悬赏园豆:30 [已解决问题] 解决于 2021-05-28 16:05
sql=“select Code, StudentName  from [Student]”
if(TeacherName!=""){
   sql+=" ,[Teacher] where [Student].TeacherName = [Teacher] .TeacherName Where         [Teacher].TeacherName=TeacherName"
}
你猜丶的主页 你猜丶 | 初学一级 | 园豆:135
提问于:2020-11-18 18:23
< >
分享
最佳答案
0
            var teacherName = string.Empty;
            var teachers = new List<(string Code, string TeacherName)>();
            new List<(string Code, string StudentName, string TeacherName)>()
                .Where(t => !string.IsNullOrEmpty(teacherName) && teachers.Any(g => g.TeacherName == teacherName));

 

闲来无聊,预计是这么个意思,送一下代码。

收获园豆:30
花飘水流兮 | 专家六级 |园豆:13617 | 2020-11-24 11:35

明白了谢谢

你猜丶 | 园豆:135 (初学一级) | 2021-05-28 16:06
其他回答(1)
0

var reslut=from a in Student;
if(TeacherName!=""){
result=from a in result
join b in Teacher.where(s=>s.TeacherName.equal("TeacherName")) on a.TeacherName equal b.TeacherName
select new { a,b };
}
差不多这样吧,好久没写啦

你小子嚣张呀 | 园豆:630 (小虾三级) | 2020-11-19 15:58

咳咳不可以这样写

支持(0) 反对(0) 你猜丶 | 园豆:135 (初学一级) | 2020-11-23 10:54
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册