属性缺少linq查询结果 [英] Attribute Missing from linq query result

查看:65
本文介绍了属性缺少linq查询结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请在下面找到linq查询



Please find below the linq query

var result = (from sd in students
                              select sd.Student_ID).Except(from m in query1
                                                          select m.Student_ID).ToList();




来自此查询的
我得到的确切结果。现在我想填充学生的其他数据,所以我所做的是编写其他linq查询。在这里,但我没有得到 r.Student_ID 属性来与学生表进行比较。智能感知不给r.Student_ID。请帮忙!





from this query I am getting the exact results. Now I want to populate other data of students so what I have done is wrote other linq query. Below here, But I am not getting r.Student_ID attribute to compare with students table. Intellisense not giving r.Student_ID. Please help!

var finalResult = (from sd in dbcDefaulter.Student_Details
                               from r in list where r == sd.Student_ID
                               orderby sd.Student_ID
                               select new { sd.Student_ID, sd.Name, sd.Class, sd.Section, sd.F_Name, sd.F_Mobile }).Distinct().ToList();

推荐答案

1.您应该声明第一个LINQ表达式,但不要执行它,如下所示:

1.You should declare your first LINQ expression, but not to execute it, like below:
var firstQuery= from sd in students
                                from m in query1
                                where sd.Student_ID != m.Student_ID 
                              select sd.Student_ID;



2.然后在第二个查询中使用上面的第一个查询,如下所示:


2.Then use the above first query in the second one like below:

var finalResult = (from sd in dbcDefaulter.Student_Details
                                  from r in firstQuery where r.Student_ID == sd.Student_ID
                                  orderby sd.Student_ID
                                  select new { sd.Student_ID, sd.Name, sd.Class, sd.Section, sd.F_Name, sd.F_Mobile }).Distinct().ToList();


这篇关于属性缺少linq查询结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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