ObjectQuery<T> не работает в Entity Framework! Любое предложение, что использовать insted из

Я боролся с ObjectQueryНо потом я узнал, что он используется только в более ранних версиях Visual Studio. Я не знаю, что и как использовать в Visual Studio 2017. Может кто-нибудь помочь!? Как вы можете видеть, я использую Entity Framework. Я прочитал что-то о запросе, но я не знаю, можно ли использовать что-то еще, кроме этого.

    namespace POSsytemFlamenca
    {
        public partial class LaFlamencaPSO : Form
        {
            private BindingList<TblProduct> products = new BindingList<TblProduct>();
            private FlamencaProEntities1 cse = new FlamencaProEntities1();

            public LaFlamencaPSO()
            {
                InitializeComponent();
                listProductChosen.DataSource = products;
                listProductChosen.DisplayMember = "Description";
                CreateTabbedPanel();
                AddProductsToTabbedPanel();

            }

            private void AddProductsToTabbedPanel()
            {
                int i = 1;

                foreach (TabPage tp in tabControl1.TabPages)
                { 
                    // this is the problem
                    ObjectQuery<TblProduct> filteredproduct = new ObjectQuery<TblProduct>("SELECT VALUE P FROM TblProducts AS P WHERE P.ProductType = " + i.ToString(), cse);

                    FlowLayoutPanel flp = new FlowLayoutPanel();
                    flp.Dock = DockStyle.Fill;

                    foreach (TblProduct tprod in filteredproduct)
                    {
                        Button b = new Button();
                        b.Size = new Size(100, 100);
                        b.Text = tprod.Description;
                        flp.Controls.Add(b);
                    }

                    tp.Controls.Add(flp);
                    i++;
                }
            }

            private void CreateTabbedPanel()
            {
                foreach (TblProductType pt in cse.TblProductTypes)
                {
                    tabControl1.TabPages.Add(pt.ProductType.ToString(), pt.Description);
                }
            }

            private void button1_Click(object sender, EventArgs e)
            {
                TblProduct p = new TblProduct() { Description = "Product A", 
                Price = 1.99M };
                products.Add(p);
            }

            private void FormtListItem(object sender, ListControlConvertEventArgs e)
            {
                string currentDescription = ((TblProduct)e.ListItem).Description;
                string currentPrice = string.Format("{0:C}",((TblProduct)e.ListItem).Price);
                string curretDescriptionPadded = currentDescription.PadRight(30);

                e.Value = curretDescriptionPadded + currentPrice;
            }
        }
    }

1 ответ

Другие вопросы по тегам