C#中的LINQ错误味精"无法找到源类型的查询模式的实现“翻番?”。 '选择'未找到 [英] C# Linq error msg "could not find an implementation of the query pattern for source type 'double?'. 'Select' not found
问题描述
我想建立一个简单的银行应用程序,当用户进行存款,增加了兴趣。我有一个接受存款金额,当提交被点击的计算将发生在Web窗体的文本框。但我得到的无法找到源类型双?查询模式的实现。选择未找到。消息在我的code。平衡被声明为双?在会计类。有很多的解决方案,我看到的是已经在顶部添加使用System.Linq的命名空间,但我已经这样做了。
公共无效GetInterest()
{ 变种DB =新CelticSavingsBank.Classes.Accounts(); VAR myBalance =从在db.Balance
选择一个;
db.Balance = myBalance +(myBalance * 0.03); } 保护无效depositButton_Click(对象发件人,EventArgs的发送)
{
GetInterest();
}
db.Balance
是翻番?
除非你有一个非常奇怪的集扩展方法,你只能运行在LINQ查询一个的集的;即的IEnumerable< T>
I am trying to set up a simple banking application that adds interest when the user makes a deposit. I have a textbox on the webform that accepts the deposit amount and when "Submit" is clicked the calculation will take place. however I get the "could not find an implementation of the query pattern for source type 'double?'. 'Select' not found." message in my code. Balance is declared as a double? in the Accounts class. A lot of solutions I saw already were to add the using System.Linq namespace at the top but I've already done that.
public void GetInterest()
{
var db = new CelticSavingsBank.Classes.Accounts();
var myBalance = from a in db.Balance
select a;
db.Balance = myBalance + (myBalance * 0.03);
}
protected void depositButton_Click(object sender, EventArgs e)
{
GetInterest();
}
db.Balance
is a double?
.
Unless you have a very weird set of extension method, you can only run LINQ queries over a collection; namely, IEnumerable<T>
.
这篇关于C#中的LINQ错误味精&QUOT;无法找到源类型的查询模式的实现“翻番?”。 '选择'未找到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!