本文介绍了如何修复参数2:无法从实体'转换为'system.data.entity.core.objects.objectcontext的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

private void AddProductsToTabbedPanel()
        {
            int i = 1;

            foreach (TabPage tp in tabControl1.TabPages)
            {
                ObjectQuery<tblproduct> filteredProduct = new ObjectQuery<tblproduct>("SELECT VALUE P FROM tblProduct AS P WHERE P.ProductType=" + i.ToString(),pce);

                FlowLayoutPanel flp = new FlowLayoutPanel
                {
                    Dock = DockStyle.Fill
                };

                foreach (tblProduct tprod in filteredProduct)
                {
                    Button b = new Button
                    {
                        Size = new Size(100, 100),
                        Text = tprod.Description,
                        Tag = tprod
                    };
                    b.Click += new EventHandler(UpdateProductList);

                    tp.Controls.Add(b);
                    flp.Controls.Add(b);
                }



和这里


and here

private void FilterList(object sender, EventArgs e)
        {
            ObjectQuery<tblproduct> filteredProducts = new ObjectQuery<tblproduct>("SELECT VALUE product FROM tblProducts AS product WHERE product.ProductType = " + cboFilter.SelectedValue,pce);
            dataGridView1.DataSource = filteredProducts;
        }





我的尝试:



尝试将EF模型更新到最新版本,但该问题解决了问题



What I have tried:

tried to update EF model to latest version but that dosent fix the problem

推荐答案


这篇关于如何修复参数2:无法从实体'转换为'system.data.entity.core.objects.objectcontext的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-11 16:12