新手求指教 Winform Entity Framework 我在每个窗体里这么写合适吗?

和MVC的写法一样

namespace TestWinForm.ViewForms.ViewAll
{
public partial class ViewPlansForm : Form
{
TestEntities db = new TestEntities();

    public ViewPlansForm()
    {
        InitializeComponent();
    }

    private void barEditItem1_EditValueChanged(object sender, EventArgs e)
    {
        DateTime dateTime = Convert.ToDateTime(this.barEditItem1.EditValue);

        var planModels = from m in db.Plans where m.StartTime == dateTime select m;
        var PlanList = planModels.ToList();
        this.gridControl1.DataSource = PlanList;

    }
}

}

0
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!