如何获取列值为true的列名

如何获取列值为true的列名

本文介绍了如何获取列值为true的列名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

i want to find out all column name which value is true in database by linq query and want to show as text in label




var power = from st in obj.admin_login_tables
                       where st.user_name == uname
                       select new {a = st.user_detail_edit,b = st.Order_status,c = st.Order_status_edit,d = st.user_detail_show,f = st.book_post, };




so above is my query in which m try to finding the true values column but m not  this 
and thanx in advance

推荐答案

DataClasses1DataContext obj = new DataClasses1DataContext();

        string name = "somename";
        var power = from st in obj.admin_login_tables
                    where st.User_name == name
                    select new { a = st.user_detail_edit, b = st.Order_status, c = st.Order_status_edit, d = st.user_detail_show, f = st.book_post, };
       var temp =  power.FirstOrDefault();
       if (temp != null)
       {
           if (temp.a)
               lbl.Text = "a,";
           if (temp.b)
               lbl.Text += "b,";
           if (temp.c)
               lbl.Text += "c,";
           if (temp.d)
               lbl.Text += "d,";
           if (temp.f)
               lbl.Text += "f,";
           lbl.Text = lbl.Text.Trim(',');

       }


这篇关于如何获取列值为true的列名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-19 03:37