C# Visual Studio 2013.NET Framework 4中ObjectQuery的问题
我正在为一家医院的自助餐厅做POS,我正在youtube上观看一些视频,介绍如何用c做POS,但我进入了这一部分,他使用ObjectQuery类,当我声明对象的实例时,它给了我以下错误: 错误2参数2:无法从转换 “自助餐厅位置EF4.BVH位置DB模式EF43”至 'System.Data.Objects.ObjectContext'c:\users\tony's\documents\visual 演播室 2013\projects\caffeeta\u pos\u ef4\caffeeta\u pos\u ef4\cash register.cs 46 119 caffeeta\u pos\u ef4 还有这个: 错误1与的最佳重载方法匹配 'System.Data.Objects.ObjectQuery.ObjectQuerystring, System.Data.Objects.ObjectContext“”具有一些无效的 参数c:\users\tony's\documents\visualstudio 2013\projects\caffeeta\u pos\u ef4\caffeeta\u pos\u ef4\cash register.cs 46 49 caffeeta\u pos\u ef4 我试图在互联网上搜索一些解决方案或其他东西,但我只找到了旧的教程,我无法理解Microsoft关于如何发送构造函数参数的说明。。。我正在使用.NET framework 4和Visual Studio 2013 PS-我想使用ObjectQuery,因为我想执行foreach循环,从数据库中的项动态填充TabControlC# Visual Studio 2013.NET Framework 4中ObjectQuery的问题,c#,visual-studio-2013,objectquery,C#,Visual Studio 2013,Objectquery,我正在为一家医院的自助餐厅做POS,我正在youtube上观看一些视频,介绍如何用c做POS,但我进入了这一部分,他使用ObjectQuery类,当我声明对象的实例时,它给了我以下错误: 错误2参数2:无法从转换 “自助餐厅位置EF4.BVH位置DB模式EF43”至 'System.Data.Objects.ObjectContext'c:\users\tony's\documents\visual 演播室 2013\projects\caffeeta\u pos\u ef4\caffeeta\
ObjectQuery<pos_item> filteredProduct = new ObjectQuery<pos_item>("SELECT VALUE P FROM pos_item AS P WHERE P.pos_item_group = " + i.ToString(), cse);
如果你们不想看到全班同学,我会把它贴在下面,提前感谢你们的时间和努力
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.Objects;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Cafeteria_POS_EF4
{
public partial class CashRegister : Form
{
private BindingList<pos_item> products = new BindingList<pos_item>();
private BVH_POS_DB_MODEL_EF43 cse = new BVH_POS_DB_MODEL_EF43();
public CashRegister()
{
InitializeComponent();
lboxBasket.DataSource = products;
lboxBasket.DisplayMember = "description";
//pos_item p = new pos_item() { };
CreateTabbedPanel();
FillTabbedPanel();
}
private void CreateTabbedPanel()
{
foreach(pos_item_group ig in cse.pos_item_group)
{
tabControl.TabPages.Add(ig.item_group_id.ToString(), ig.item_group_name);
}
}
private void FillTabbedPanel()
{
int i = 1;
foreach(TabPage tp in tabControl.TabPages)
{
ObjectQuery<pos_item> filteredProduct = new ObjectQuery<pos_item>("SELECT VALUE P FROM pos_item AS P WHERE P.pos_item_group = " + i.ToString(), cse);
FlowLayoutPanel flp = new FlowLayoutPanel();
flp.Dock = DockStyle.Fill;
foreach (pos_item item in filteredProduct)
{
Button b = new Button();
b.Text = item.description;
tp.Controls.Add(b);
}
tp.Controls.Add(flp);
i++;
}
}
}
}我在论坛上找到了这个答案,解决了我的问题 代码仍然不会运行,因为foreach循环中出现异常 参数类型“POS_DB_MODEL.POS_item_group”和“Edm.Int32”与此操作不兼容。在WHERE谓词附近,第1行,第58列