首页 新闻 搜索 专区 学院

这句sql如何翻译成linq?

0
悬赏园豆:30 [待解决问题]
sql=“select Code, StudentName  from [Student]”
if(TeacherName!=""){
   sql+=" ,[Teacher] where [Student].TeacherName = [Teacher] .TeacherName Where         [Teacher].TeacherName=TeacherName"
}
你猜丶的主页 你猜丶 | 菜鸟二级 | 园豆:210
提问于:2020-11-18 18:23
< >
分享
所有回答(2)
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 };
}
差不多这样吧,好久没写啦

wwr01 | 园豆:643 (小虾三级) | 2020-11-19 15:58

咳咳不可以这样写

支持(0) 反对(0) 你猜丶 | 园豆:210 (菜鸟二级) | 2020-11-23 10:54
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));

 

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

花飘水流兮 | 园豆:12303 (专家六级) | 2020-11-24 11:35
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册