I need to do this in entity framework

roni

New member
Joined
Aug 1, 2021
Messages
2
Programming Experience
Beginner
methods:
private void LoadData()
{



            flowLayoutPanel1.Controls.Clear();
            int i;
            cn.Open();
          
            cm = new SqlCommand("select photo,Barcod,Name,Price from Items  ", cn);
          
            dr = cm.ExecuteReader();
            while (dr.Read())
            {
                long len = dr.GetBytes(0, 0, null, 0, 0);
                byte[] array = new byte[System.Convert.ToInt32(len) + 1];
                dr.GetBytes(0, 0, array, 0, System.Convert.ToInt32(len));

                pic = new PictureBox();
                pic.Width = 70;
                pic.Height = 100;
                pic.BorderStyle = BorderStyle.Fixed3D;

                pic.BackgroundImageLayout = ImageLayout.Stretch;
                pic.Tag = dr["Barcod"].ToString();


                Name = new Label();
                Name.Text = dr["Name"].ToString();
                Name.BackColor = Color.FromArgb(46, 134, 222);
                Name.TextAlign = ContentAlignment.MiddleCenter;
                Name.Dock = DockStyle.Bottom;
                Name.ForeColor = Color.White;
                Name.Tag = dr["Barcod"].ToString();

                Price = new Label();
                Price.Text = dr["Price"].ToString();
                Price.Width = 30;
                Price.BackColor = Color.FromArgb(255, 121, 121);
                Price.TextAlign = ContentAlignment.MiddleCenter;







                MemoryStream ms = new MemoryStream(array);
                Bitmap bitmap = new Bitmap(ms);
                pic.BackgroundImage = bitmap;
                pic.Controls.Add(Name);
                pic.Controls.Add(Price);


                flowLayoutPanel1.Controls.Add(pic);
                pic.Cursor = Cursors.Hand;
                pic.Click += new EventHandler(OnClick);


                //pic.Click += (sender, e) => OnClick(this, e, pic.Tag.ToString());
                //Price.Click += (sender, e) => OnClick(this, e, Price.Tag.ToString());

            }
            dr.Close();
            cn.Close();
}

I need to make this method original but in entity framework How can Help me?
 
A post with nothing but code is never acceptable. Provide a FULL and CLEAR explanation of the problem, i.e. explain exactly what you're trying to achieve, how you're trying to achieve it and what happens when you try. If you haven't tried anything yet, you haven't encountered an issue yet, so it's too soon to post. If you don't know enough about EF yet to try anything then you need to spend some time learning about EF. There's little point our providing a specific solution to one specific problem if you don't understand any of the principles involved because then you'll be back asking for more code as soon as the specifics of the scenario change at all. If you have an EF model then you need to describe the relevant parts of it to us. If you don't have a model then it's definitely too soon to be posting a question on how to use it. Once you have a model, you need to try to query it in the way that your research leads you to believe is appropriate. If that doesn't work, THEN you have a question to ask us here.
 
Moving out of IDE and into Entity Framework...
 
Back
Top Bottom