c# - 无法隐式转换类型'bool ?' to bool on "whereapprovmentState=true"

标签 c# compiler-errors

关闭。这个问题是not reproducible or was caused by typos .它目前不接受答案。












想改进这个问题?将问题更新为 on-topic对于堆栈溢出。

7年前关闭。




Improve this question




我在 asp.net Entity Framework 中使用 C# 和 LINQ to SQL。

当复选框被选中时,我想从数据库中显示“approvementState”列值为假的列表,并且当复选框未被选中时;然后获取记录哪些列批准状态为真。

html:

<asp:CheckBox runat="server" ID="cbInternsApproval" Text="View Approved Interns" AutoPostBack="True" Checked="False" OnCheckedChanged="cbInternsApproval_CheckedChanged"/>

C#代码:
protected void cbInternsApproval_CheckedChanged(object sender, EventArgs e)
        {
            if (cbInternsApproval.Checked)
            {
                using (PROJECT_DBEntities3 context=new PROJECT_DBEntities3())
                {

                    var lst=(from f in context.FirstInternships
                                 where f.approvementState==true // error in this line of code
                                 select f).ToList();
                }
            }
        }

但我收到错误:无法隐式转换类型'bool? bool 值。存在显式转换。

最佳答案

其中 f.approvementState == true

关于c# - 无法隐式转换类型'bool ?' to bool on "whereapprovmentState=true",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25675015/

相关文章:

c# - 将十六进制代码转换为颜色名称

c++ - 为 ARM 平台编译库时出错

c# - Web 服务器上的 WAV/MP3 转换

c# - C# 日期时间和 SQL 日期时间之间的相等性比较失败

c++ - 在 Arduino IDE 中使用正则表达式库时未定义对 `longjmp' 的引用

python - 使用lmfit时“ValueError: The input contains nan values”

java - 类型转换时不一致(错误: Incompatible types)

java - Java 中的合法注释内容导致错误

c# - 如何从 Windows 7 上的 C# 程序读取 Android 手机上的文件?

c# - ListView 跳过第一列