first of all I am very new (noob). Probably my question is very stupid but I got stuck. Here is the situation.
I started programming a winforms database application using EF 5.0 . Everything is fine I can do what I want in forms like this:
private void Form1_Load(object sender, EventArgs e)
{
using (var ctx = new pehkEntities())
{
var result = from k in ctx.Kolons
select new
{
KolonAdı = k.KolonAdi,
En = k.En,
Boy = k.Boy,
Yükseklik = k.Yukseklik,
ID = k.KolonID
};
dataGridView1.DataSource = result.ToList();
}
}
But my form1 codes are really messed up right now and I want to clean it by using classes and methods. I tried to create a class and a method in program.cs but I have failed. How should I fix it?
public class veritabani_islemleri
{
public ???? kolonlistele()
{
using(pehkEntities ctx = new pehkEntities())
var result =from k in ctx.Kolons
select new
{
KolonAdı = k.KolonAdi,
En = k.En,
Boy = k.Boy,
Yükseklik = k.Yukseklik,
ID = k.KolonID
};
return ????
}
}
My problem is I can not fill the question marks. I just want to do this in my form.
private void Form1_Load(object sender, EventArgs e)
{
dataGridview.DataSource=myfunction();
}
Or if my method is completely wrong how should I do this?