我在wpf项目中有一个usercontrol,它执行一个需要很长时间的select查询 这是代码
Entities1 context = new Entities1();
ObservableCollection<E> _E = new ObservableCollection<E>();
CollectionViewSource ECollection = new CollectionViewSource();
ECollection = (CollectionViewSource)this.Resources["EResource"];
this._E = new ObservableCollection<E>
(from e in context.Es
join eg in context.EQ_Gs on e.EQ_G_ID equals eg.EQ_G_ID
join u in context.Us on e.U_ID equals u.U_ID
join b in context.Bs on e.B_ID equals b.B_ID
select e);
ECollection.Source = this._E;
this.Grid_E.ItemsSource = this._E;
this.Grid_E.DataContext = this._E;
this.DataContext = ECollection;
表E有30000条记录 加载用户控件需要2.5分钟 如果你有任何想法来提高性能,它会帮助我很多 提前致谢和问候
答案 0 :(得分:0)
谢谢亲爱的杰夫·梅尔卡多
我更改了查询并使用了热切的加载查询,它帮助了很多并减少了加载时间。
var query = context.E.include("B").tostring()