I have a usercontrol in wpf project whic it execute a select query which takes a long time this is the code
我在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;
and table E has 30000 record it takes aound 2.5 min to load the usercontrol if you have any idea to improve performance it would help me alot thanks and regards in advance
并且表E有30000条记录,加载用户控制需要2.5分钟,如果你有任何想法提高性能它会帮助我提前多多谢谢和问候
1 个解决方案
#1
0
Thanks dear Jeff Mercado
谢谢亲爱的杰夫梅尔卡多
I changed the query and used eager loading query it helped a lot and reduced loading time. var query = context.E.include("B").tostring()
我改变了查询并使用了热切的加载查询,它帮助了很多,减少了加载时间。 var query = context.E.include(“B”)。tostring()
#1
0
Thanks dear Jeff Mercado
谢谢亲爱的杰夫梅尔卡多
I changed the query and used eager loading query it helped a lot and reduced loading time. var query = context.E.include("B").tostring()
我改变了查询并使用了热切的加载查询,它帮助了很多,减少了加载时间。 var query = context.E.include(“B”)。tostring()