gpt4 book ai didi

c# - 使用 .mdf 数据库的 C# 表单应用程序中的 Linq to sql 问题

转载 作者:行者123 更新时间:2023-11-30 22:33:15 25 4
gpt4 key购买 nike

我在使用 C# 表单应用程序时遇到问题。我正在连接到 .mdf 数据库并尝试查询名为 SpotLanding 的 bool 列,然后计算为真的数字。它位于 LogbookDatabase.mdf 和表 EnterTable 中。这是我目前所拥有的:

    private void SpotLandingButton_Click(object sender, EventArgs e)
{

DataContext db = new DataContext(@"C:\LogbookDatabase.mdf");
Table<EnterTable> entrytable = db.GetTable<EnterTable>();
var spot = (from SpotLanding in entrytable
where SpotLanding = true
select SpotLanding).Count;

return spot;
}

这是它给我的错误;

Cannot implicitly convert type 'bool' to 'ParagliderLogBook.EnterTable'

任何人都可以提供的任何信息都会很棒。我尝试了很多不同的方法来完成这个并提出了同样的错误。

最佳答案

您需要使用 == 运算符而不是 =

var spot = (from SpotLanding in entrytable
where SpotLanding == true
select SpotLanding).Count;

关于c# - 使用 .mdf 数据库的 C# 表单应用程序中的 Linq to sql 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8393265/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com