简体   繁体   English

使用布尔类型的动态ListItem列构造一个linq查询

[英]Constructing a linq query with dynamic ListItem columns that are type boolean

"selectedBA" is the variable that contains a value determined @ runtime. “ selectedBA”是包含在运行时确定的值的变量。 how can i incorporate this into a linq statement that will give me all the items in a SPList where the dynamic column selectedBA is True in the item. 我如何将其合并到linq语句中,该语句将为我提供SPList中的所有项目,其中动态列selectedBA在项目中为True。 Probably something simple i am over thinking... the dynamic column is Type Boolean in the SPList 可能是我考虑过一些简单的事情...动态列在SPList中是Boolean类型

DataTable dt = siteTemplateList.GetItems().GetDataTable();
var query = from template in dt.AsEnumerable()
            where template[selectedBA].Equals(true)
            select template;

try 尝试

DataTable dt = siteTemplateList.GetItems().GetDataTable();
var query = from template in dt.Rows
            where template[selectedBA].Equals(true)
            select template;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM