2 p19359899 p19359899 于 2016.03.11 10:29 提问

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

    }
}

}

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!