LINQ似乎正在减缓应用程序 [英] LINQ seems to be slowing down application

查看:106
本文介绍了LINQ似乎正在减缓应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我似乎对LINQ有问题,我目前正在维护内部Intranet应用程序.当保存日志时,它现在似乎变慢了,在调试时,我开始意识到,每次保存日志时,应用程序都会在这两行代码处暂停.它确实保存了日志,只是速度很慢,有时甚至是超慢.

DataClassesDataContext dab = new DataClassesDataContext();

dab.SubmitChanges();



我的主要问题是,这两条特殊的代码行是否存在任何已知问题,会给应用程序带来任何问题,从而减慢应用程序的运行速度?下面是用于插入的完整代码,那些了解得更好的人也许可以对其进行更好地分析,并在错误的地方纠正我.提前谢谢...

DataClassesDataContext dab = new DataClassesDataContext();

newlog = new calllog();
newlog.shortdesc = txtshortdesc.Text;
 calllog_description.Text ="*****" +  Page.User.Identity.Name + " " + DateTime.Now.ToString() + " ***** " +  "\r\n" + calllog_description.Text;
 newlog.calllog_description = calllog_description.Text;
 newlog.calllog_id = Convert.ToInt32(txtlogid.Text);
 newlog.calllogrefno = calllogrefno.Text;
 newlog.pr_id = Convert.ToInt32(pr_id.SelectedItem.Value);
 newlog.st_id = Convert.ToInt32(st_id.SelectedValue);
 newlog.product_id = Convert.ToInt32(product_id.SelectedValue);
 newlog.dep_id = Convert.ToInt32(dep_id.SelectedValue);
 newlog.log_assigneduser = Convert.ToInt32(log_assigneduser.SelectedValue);
 newlog.client_id = Convert.ToInt32(DropDownList1.SelectedValue);
 newlog.log_datetime = System.DateTime.Now;
 newlog.log_user_id = this.Page.User.Identity.Name;
 newlog.calllog_internal = calllog_internal.Checked;
 newlog.notify_client = true;
 newlog.notify_practise = true;
 newlog.ct_id = Convert.ToInt32(ct_id.SelectedValue);
 newlog.resolved = false;
 dab.calllogs.InsertOnSubmit(newlog);

 dab.SubmitChanges();

解决方案

也许这会帮助实体框架性能 [ ^ ]

Hi all, I seem to be having an issue with LINQ, I am currently maintaining an in house Intranet application at work. When Saving logs it seems to slow down now, upon debugging I have came to realise that everytime it saves a log the application pauses at these two section lines of codes. It does save the logs, just that its slow and at times superslow.

DataClassesDataContext dab = new DataClassesDataContext();

dab.SubmitChanges();



My question primarily is, are there any known issues with those two paticuler lines of code giving any sort of problem that can slow down an application? Below is the full code used for inserting, those who understand better could perhaps analyse it better and perhaps correct me where im wrong. Thanks in advance...

DataClassesDataContext dab = new DataClassesDataContext();

newlog = new calllog();
newlog.shortdesc = txtshortdesc.Text;
 calllog_description.Text ="*****" +  Page.User.Identity.Name + " " + DateTime.Now.ToString() + " ***** " +  "\r\n" + calllog_description.Text;
 newlog.calllog_description = calllog_description.Text;
 newlog.calllog_id = Convert.ToInt32(txtlogid.Text);
 newlog.calllogrefno = calllogrefno.Text;
 newlog.pr_id = Convert.ToInt32(pr_id.SelectedItem.Value);
 newlog.st_id = Convert.ToInt32(st_id.SelectedValue);
 newlog.product_id = Convert.ToInt32(product_id.SelectedValue);
 newlog.dep_id = Convert.ToInt32(dep_id.SelectedValue);
 newlog.log_assigneduser = Convert.ToInt32(log_assigneduser.SelectedValue);
 newlog.client_id = Convert.ToInt32(DropDownList1.SelectedValue);
 newlog.log_datetime = System.DateTime.Now;
 newlog.log_user_id = this.Page.User.Identity.Name;
 newlog.calllog_internal = calllog_internal.Checked;
 newlog.notify_client = true;
 newlog.notify_practise = true;
 newlog.ct_id = Convert.ToInt32(ct_id.SelectedValue);
 newlog.resolved = false;
 dab.calllogs.InsertOnSubmit(newlog);

 dab.SubmitChanges();

解决方案

Perhaps this will help Entity Framework Performance[^]


这篇关于LINQ似乎正在减缓应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆