专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > LINQ

请教linq查询有关问题

发布时间:2011-06-24 21:55:50 文章来源:www.iduyao.cn 采编人员:星星草
请教linq查询问题?
有如下的数据表:
字段1 字段2 字段3 字段4 字段5 字段6 字段7 字段8
T F T T F F F T
F F T F F T T F
T T T F F F F F
T F T F T F T F
T T T T T T T T
……
我想查询所有字段值都为T的记录,那么linq语句该怎么写,是要在where语句里面写“where 字段1=T and 字段2=T and……”这样么?

------解决方案--------------------
C# code

void Main()
{
        var queryResults =
        from c in dbContxt.customers
        let cloumns=dbContxt.ExecuteQuery<temp>("select   name  from   syscolumns   where   id=object_id(N'customers')","");
        where cloumns.All(d=>GetPropertyValue(c,d.name)=="T")
         select c;
     
}
public class temp
{
  public string name{get;set;}
}
private static object GetPropertyValue(object obj, string property)  
{  
    System.Reflection.PropertyInfo propertyInfo=obj.GetType().GetProperty(property);  
    return propertyInfo.GetValue(obj, null);  
}
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: