本文介绍了如何在linq中包含哪个类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 以下是我的代码 < blockquote class = FQ>< div class = FQA> Quote:< / div > public static 列表< OverallCompliance> GetOverallCompliance( string str) { List< OverallCompliance> overall_compliance = new 列表< OverallCompliance>(); 尝试 { 使用(BaseEntities entity = new BaseEntities()) { overall_compliance = entity.mssp_eps_compliance_report 。选择(s = > ; new {s.ID,s.REPORT_TYPE,s.REPORT_DATE,s.COMPLIANT,s.NON_COMPLIANT}) .AsEnumerable() 。选择(x = > new OverallCompliance { id = int .Parse(x.ID.ToString()), type = x.REPORT_TYPE, date = x.REPORT_DATE, compliant = int .Parse(x.COMPLIANT), non_compliant = int .Parse(x.NON_COMPLIANT)})。ToList(); } } catch (Exception ex){} return overall_compliance; } < / blockquote > 当从entity.entity.mssp_eps_compliance_report中获取值时 我需要过滤值通过使用str == s.REPORT_TYPE,然后我需要选择所有这些值..请帮忙。提前谢谢解决方案 Hi,Below is my code <blockquote class="FQ"><div class="FQA">Quote:</div>public static List<OverallCompliance> GetOverallCompliance(string str) { List<OverallCompliance> overall_compliance = new List<OverallCompliance>(); try { using (BaseEntities entity = new BaseEntities()) { overall_compliance = entity.mssp_eps_compliance_report .Select(s => new { s.ID, s.REPORT_TYPE, s.REPORT_DATE, s.COMPLIANT, s.NON_COMPLIANT }) .AsEnumerable() .Select(x => new OverallCompliance { id = int.Parse(x.ID.ToString()), type = x.REPORT_TYPE, date = x.REPORT_DATE, compliant = int.Parse(x.COMPLIANT), non_compliant = int.Parse(x.NON_COMPLIANT) }).ToList(); } } catch (Exception ex) { } return overall_compliance; }</blockquote>When fectching the value from entity.entity.mssp_eps_compliance_reportI need to filter the value by using where str == s.REPORT_TYPE, and then I need to select all these values.. Please help. Thanks in advance 解决方案 这篇关于如何在linq中包含哪个类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-20 12:27