p19359899
p19359899
2016-03-11 02:29
采纳率: 60%
浏览 986

新手求指教 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;

    }
}

}

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

相关推荐