Iterating in a list of data and search data in another datatableSearch datatable fasterConverting List to a DataTable and/or DataSet Extension MethodsSpeeding up Parallel.ForEach iterating through datatable and rendering reportConvert datagridview data to DataTableList<List<string>> vs DataTableSort and merge list based on another listAdd data to DataTableLeetcode 10: Regular Expression MatchingList of classes to datatableHandler for jQuery DataTable search with filters and pagination
Approximately how much travel time was saved by the opening of the Suez Canal in 1869?
What are these boxed doors outside store fronts in New York?
To string or not to string
Is it important to consider tone, melody, and musical form while writing a song?
How do we improve the relationship with a client software team that performs poorly and is becoming less collaborative?
What defenses are there against being summoned by the Gate spell?
Can a Warlock become Neutral Good?
What are the differences between the usage of 'it' and 'they'?
Is it tax fraud for an individual to declare non-taxable revenue as taxable income? (US tax laws)
Why can't I see bouncing of a switch on an oscilloscope?
How to find program name(s) of an installed package?
Example of a continuous function that don't have a continuous extension
Maximum likelihood parameters deviate from posterior distributions
Smoothness of finite-dimensional functional calculus
LaTeX closing $ signs makes cursor jump
How old can references or sources in a thesis be?
"to be prejudice towards/against someone" vs "to be prejudiced against/towards someone"
How does one intimidate enemies without having the capacity for violence?
Why was the small council so happy for Tyrion to become the Master of Coin?
If I cast Expeditious Retreat, can I Dash as a bonus action on the same turn?
Why don't electron-positron collisions release infinite energy?
Fencing style for blades that can attack from a distance
How is the claim "I am in New York only if I am in America" the same as "If I am in New York, then I am in America?
How can bays and straits be determined in a procedurally generated map?
Iterating in a list of data and search data in another datatable
Search datatable fasterConverting List to a DataTable and/or DataSet Extension MethodsSpeeding up Parallel.ForEach iterating through datatable and rendering reportConvert datagridview data to DataTableList<List<string>> vs DataTableSort and merge list based on another listAdd data to DataTableLeetcode 10: Regular Expression MatchingList of classes to datatableHandler for jQuery DataTable search with filters and pagination
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
$begingroup$
I have a list which has 25000 data and I am iterating in all data and in each iteration, I am searching data in another data table. my whole routine is taking a long time to finish.
private void UpdateCommentFirst(string strCommentPath, string TickerName)
int counter = 0;
bool QcViewAllFileExist = false;
bool QcCommentFileExist = false;
bool AllowUpdate = false;
string savepath = Convert.ToString(ConfigurationManager.AppSettings["OutputPath"]).Trim() + TickerName + "\" + TickerName + "_QC-ViewwAll.xml";
DataSet QCCommentstmp = new DataSet();
DataSet QCViewAlltmp = new DataSet();
if (File.Exists(strCommentPath))
QCCommentstmp.ReadXml(strCommentPath);
QcCommentFileExist = true;
if (File.Exists(savepath))
QCViewAlltmp.ReadXml(savepath);
QcViewAllFileExist = true;
if (QcCommentFileExist && QcViewAllFileExist)
if (QCCommentstmp.Tables.Count > 0)
if (!QCCommentstmp.Tables[0].Columns.Contains("IgnoreData"))
AllowUpdate = true;
if (AllowUpdate)
List<clsCommentPopup> QCCommentlist = QCCommentstmp.Tables[0].AsEnumerable()
.Select(row => new clsCommentPopup
//BrokerFor,Formula,LineItem,Section,PeriodCollection
bolFollowUP = (row.Field<string>("FollowUP")) == null ? false : Convert.ToBoolean((row.Field<string>("FollowUP"))),
bolThisPeriod = (row.Field<string>("ThisPeriod")) == null ? false : Convert.ToBoolean((row.Field<string>("ThisPeriod"))),
Formula = (row.Field<string>("Formula")) == null ? string.Empty : (row.Field<string>("Formula")),
ModelValue = (row.Field<string>("ModelValue")) == null ? string.Empty : (row.Field<string>("ModelValue")),
ExternalComment = (row.Field<string>("ExternalComment")) == null ? string.Empty : (row.Field<string>("ExternalComment")),
InternalComment = (row.Field<string>("InternalComment")) == null ? string.Empty : (row.Field<string>("InternalComment")),
strEndPeriod = (row.Field<string>("EndPeriod")) == null ? string.Empty : (row.Field<string>("EndPeriod")),
strStartPeriod = (row.Field<string>("StartPeriod")) == null ? string.Empty : (row.Field<string>("StartPeriod")),
PeriodType = (row.Field<string>("PeriodType")) == null ? string.Empty : (row.Field<string>("PeriodType")),
SectionFor = (row.Field<string>("Section")) == null ? string.Empty : (row.Field<string>("Section")),
LiFor = (row.Field<string>("LineItem")) == null ? string.Empty : (row.Field<string>("LineItem")),
QcPeriodFor = (row.Field<string>("QcPeriod")) == null ? string.Empty : (row.Field<string>("QcPeriod")),
BrokerFor = (row.Field<string>("BrokerFor")) == null ? string.Empty : (row.Field<string>("BrokerFor")),
PeriodCollection = (row.Field<string>("PeriodCollection")) == null ? string.Empty : (row.Field<string>("PeriodCollection")),
boolIgnoreValue = (row.Field<string>("IgnoreValue")) == null ? false : Convert.ToBoolean((row.Field<string>("IgnoreValue"))),
IgnoreData = (!QCCommentstmp.Tables[0].Columns.Contains("IgnoreData") ? string.Empty : (row.Field<string>("IgnoreData") == null ? string.Empty : row.Field<string>("IgnoreData")))
).ToList();
if (QCCommentlist != null)
foreach (var comment in QCCommentlist)
string section = comment.SectionFor;
string li = comment.LiFor;
string broker = comment.BrokerFor;
string period = comment.PeriodCollection;
string strQCPeriodValue = "";
if (comment.boolIgnoreValue && period.Trim() != "")
var QcViewColumnName = QCViewAlltmp.Tables[0].Columns.Cast<DataColumn>().AsParallel()
.Where(x => x.ColumnName.Contains(period))
.Select(x => new x.ColumnName ).FirstOrDefault();
if (QcViewColumnName != null)
period = QcViewColumnName.ColumnName;
if (period.Trim() != "")
var datarow = QCViewAlltmp.Tables[0].AsEnumerable().AsParallel()
.Where(row => row.Field<string>("GroupKey").Split('~')[0].ToUpper() == section.ToUpper()
&& row.Field<string>("GroupKey").Split('~')[1].ToUpper() == li.ToUpper()
&& row.Field<string>("Section ").ToUpper() == broker.ToUpper());
if (datarow != null && datarow.Count() > 0)
strQCPeriodValue = (datarow.FirstOrDefault()[period] != null ? datarow.FirstOrDefault()[period].ToString() : string.Empty);
if (strQCPeriodValue.Trim() != string.Empty)
comment.IgnoreData = strQCPeriodValue;
counter++;
SerializeQcComment(QCCommentlist);
toolTip1.Hide(this);
Loading data from XML file into a dataset.
If the ignoredata
field is there in QCCommentstmp
dataset table QCCommentstmp.Tables[0].Columns.Contains("IgnoreData")
then deserialize QCCommentstmp table data to list List<clsCommentPopup> QCCommentlist
.
Iterate in QCCommentlist
's data using a for
loop and finding data in QCViewAlltmp.Tables[0]
data table for each iteration.
When QCCommentlist
has 25000 data then I am iterating in all 25000 data and finding data in another data table. If data is found then I am updating data in the list. This process is getting very slow and the code is taking a long time to finish all the iteration and searching data in the data table.
Please review my code and tell me how to restructure my code, as a result, there will be the improvement in code execution speed.
If my approach is wrong then guide me with the right approach and also give me the relevant code which I can use in my above code, as a result, my routine will take minimum time to finish if I iterate in more than 25000 data. I'm looking for suggestions and better code to achieve the same task.
c#
New contributor
$endgroup$
add a comment |
$begingroup$
I have a list which has 25000 data and I am iterating in all data and in each iteration, I am searching data in another data table. my whole routine is taking a long time to finish.
private void UpdateCommentFirst(string strCommentPath, string TickerName)
int counter = 0;
bool QcViewAllFileExist = false;
bool QcCommentFileExist = false;
bool AllowUpdate = false;
string savepath = Convert.ToString(ConfigurationManager.AppSettings["OutputPath"]).Trim() + TickerName + "\" + TickerName + "_QC-ViewwAll.xml";
DataSet QCCommentstmp = new DataSet();
DataSet QCViewAlltmp = new DataSet();
if (File.Exists(strCommentPath))
QCCommentstmp.ReadXml(strCommentPath);
QcCommentFileExist = true;
if (File.Exists(savepath))
QCViewAlltmp.ReadXml(savepath);
QcViewAllFileExist = true;
if (QcCommentFileExist && QcViewAllFileExist)
if (QCCommentstmp.Tables.Count > 0)
if (!QCCommentstmp.Tables[0].Columns.Contains("IgnoreData"))
AllowUpdate = true;
if (AllowUpdate)
List<clsCommentPopup> QCCommentlist = QCCommentstmp.Tables[0].AsEnumerable()
.Select(row => new clsCommentPopup
//BrokerFor,Formula,LineItem,Section,PeriodCollection
bolFollowUP = (row.Field<string>("FollowUP")) == null ? false : Convert.ToBoolean((row.Field<string>("FollowUP"))),
bolThisPeriod = (row.Field<string>("ThisPeriod")) == null ? false : Convert.ToBoolean((row.Field<string>("ThisPeriod"))),
Formula = (row.Field<string>("Formula")) == null ? string.Empty : (row.Field<string>("Formula")),
ModelValue = (row.Field<string>("ModelValue")) == null ? string.Empty : (row.Field<string>("ModelValue")),
ExternalComment = (row.Field<string>("ExternalComment")) == null ? string.Empty : (row.Field<string>("ExternalComment")),
InternalComment = (row.Field<string>("InternalComment")) == null ? string.Empty : (row.Field<string>("InternalComment")),
strEndPeriod = (row.Field<string>("EndPeriod")) == null ? string.Empty : (row.Field<string>("EndPeriod")),
strStartPeriod = (row.Field<string>("StartPeriod")) == null ? string.Empty : (row.Field<string>("StartPeriod")),
PeriodType = (row.Field<string>("PeriodType")) == null ? string.Empty : (row.Field<string>("PeriodType")),
SectionFor = (row.Field<string>("Section")) == null ? string.Empty : (row.Field<string>("Section")),
LiFor = (row.Field<string>("LineItem")) == null ? string.Empty : (row.Field<string>("LineItem")),
QcPeriodFor = (row.Field<string>("QcPeriod")) == null ? string.Empty : (row.Field<string>("QcPeriod")),
BrokerFor = (row.Field<string>("BrokerFor")) == null ? string.Empty : (row.Field<string>("BrokerFor")),
PeriodCollection = (row.Field<string>("PeriodCollection")) == null ? string.Empty : (row.Field<string>("PeriodCollection")),
boolIgnoreValue = (row.Field<string>("IgnoreValue")) == null ? false : Convert.ToBoolean((row.Field<string>("IgnoreValue"))),
IgnoreData = (!QCCommentstmp.Tables[0].Columns.Contains("IgnoreData") ? string.Empty : (row.Field<string>("IgnoreData") == null ? string.Empty : row.Field<string>("IgnoreData")))
).ToList();
if (QCCommentlist != null)
foreach (var comment in QCCommentlist)
string section = comment.SectionFor;
string li = comment.LiFor;
string broker = comment.BrokerFor;
string period = comment.PeriodCollection;
string strQCPeriodValue = "";
if (comment.boolIgnoreValue && period.Trim() != "")
var QcViewColumnName = QCViewAlltmp.Tables[0].Columns.Cast<DataColumn>().AsParallel()
.Where(x => x.ColumnName.Contains(period))
.Select(x => new x.ColumnName ).FirstOrDefault();
if (QcViewColumnName != null)
period = QcViewColumnName.ColumnName;
if (period.Trim() != "")
var datarow = QCViewAlltmp.Tables[0].AsEnumerable().AsParallel()
.Where(row => row.Field<string>("GroupKey").Split('~')[0].ToUpper() == section.ToUpper()
&& row.Field<string>("GroupKey").Split('~')[1].ToUpper() == li.ToUpper()
&& row.Field<string>("Section ").ToUpper() == broker.ToUpper());
if (datarow != null && datarow.Count() > 0)
strQCPeriodValue = (datarow.FirstOrDefault()[period] != null ? datarow.FirstOrDefault()[period].ToString() : string.Empty);
if (strQCPeriodValue.Trim() != string.Empty)
comment.IgnoreData = strQCPeriodValue;
counter++;
SerializeQcComment(QCCommentlist);
toolTip1.Hide(this);
Loading data from XML file into a dataset.
If the ignoredata
field is there in QCCommentstmp
dataset table QCCommentstmp.Tables[0].Columns.Contains("IgnoreData")
then deserialize QCCommentstmp table data to list List<clsCommentPopup> QCCommentlist
.
Iterate in QCCommentlist
's data using a for
loop and finding data in QCViewAlltmp.Tables[0]
data table for each iteration.
When QCCommentlist
has 25000 data then I am iterating in all 25000 data and finding data in another data table. If data is found then I am updating data in the list. This process is getting very slow and the code is taking a long time to finish all the iteration and searching data in the data table.
Please review my code and tell me how to restructure my code, as a result, there will be the improvement in code execution speed.
If my approach is wrong then guide me with the right approach and also give me the relevant code which I can use in my above code, as a result, my routine will take minimum time to finish if I iterate in more than 25000 data. I'm looking for suggestions and better code to achieve the same task.
c#
New contributor
$endgroup$
$begingroup$
Break this up into smaller functions and find where you are spending the most time. This function is too complex.
$endgroup$
– pacmaninbw
5 hours ago
add a comment |
$begingroup$
I have a list which has 25000 data and I am iterating in all data and in each iteration, I am searching data in another data table. my whole routine is taking a long time to finish.
private void UpdateCommentFirst(string strCommentPath, string TickerName)
int counter = 0;
bool QcViewAllFileExist = false;
bool QcCommentFileExist = false;
bool AllowUpdate = false;
string savepath = Convert.ToString(ConfigurationManager.AppSettings["OutputPath"]).Trim() + TickerName + "\" + TickerName + "_QC-ViewwAll.xml";
DataSet QCCommentstmp = new DataSet();
DataSet QCViewAlltmp = new DataSet();
if (File.Exists(strCommentPath))
QCCommentstmp.ReadXml(strCommentPath);
QcCommentFileExist = true;
if (File.Exists(savepath))
QCViewAlltmp.ReadXml(savepath);
QcViewAllFileExist = true;
if (QcCommentFileExist && QcViewAllFileExist)
if (QCCommentstmp.Tables.Count > 0)
if (!QCCommentstmp.Tables[0].Columns.Contains("IgnoreData"))
AllowUpdate = true;
if (AllowUpdate)
List<clsCommentPopup> QCCommentlist = QCCommentstmp.Tables[0].AsEnumerable()
.Select(row => new clsCommentPopup
//BrokerFor,Formula,LineItem,Section,PeriodCollection
bolFollowUP = (row.Field<string>("FollowUP")) == null ? false : Convert.ToBoolean((row.Field<string>("FollowUP"))),
bolThisPeriod = (row.Field<string>("ThisPeriod")) == null ? false : Convert.ToBoolean((row.Field<string>("ThisPeriod"))),
Formula = (row.Field<string>("Formula")) == null ? string.Empty : (row.Field<string>("Formula")),
ModelValue = (row.Field<string>("ModelValue")) == null ? string.Empty : (row.Field<string>("ModelValue")),
ExternalComment = (row.Field<string>("ExternalComment")) == null ? string.Empty : (row.Field<string>("ExternalComment")),
InternalComment = (row.Field<string>("InternalComment")) == null ? string.Empty : (row.Field<string>("InternalComment")),
strEndPeriod = (row.Field<string>("EndPeriod")) == null ? string.Empty : (row.Field<string>("EndPeriod")),
strStartPeriod = (row.Field<string>("StartPeriod")) == null ? string.Empty : (row.Field<string>("StartPeriod")),
PeriodType = (row.Field<string>("PeriodType")) == null ? string.Empty : (row.Field<string>("PeriodType")),
SectionFor = (row.Field<string>("Section")) == null ? string.Empty : (row.Field<string>("Section")),
LiFor = (row.Field<string>("LineItem")) == null ? string.Empty : (row.Field<string>("LineItem")),
QcPeriodFor = (row.Field<string>("QcPeriod")) == null ? string.Empty : (row.Field<string>("QcPeriod")),
BrokerFor = (row.Field<string>("BrokerFor")) == null ? string.Empty : (row.Field<string>("BrokerFor")),
PeriodCollection = (row.Field<string>("PeriodCollection")) == null ? string.Empty : (row.Field<string>("PeriodCollection")),
boolIgnoreValue = (row.Field<string>("IgnoreValue")) == null ? false : Convert.ToBoolean((row.Field<string>("IgnoreValue"))),
IgnoreData = (!QCCommentstmp.Tables[0].Columns.Contains("IgnoreData") ? string.Empty : (row.Field<string>("IgnoreData") == null ? string.Empty : row.Field<string>("IgnoreData")))
).ToList();
if (QCCommentlist != null)
foreach (var comment in QCCommentlist)
string section = comment.SectionFor;
string li = comment.LiFor;
string broker = comment.BrokerFor;
string period = comment.PeriodCollection;
string strQCPeriodValue = "";
if (comment.boolIgnoreValue && period.Trim() != "")
var QcViewColumnName = QCViewAlltmp.Tables[0].Columns.Cast<DataColumn>().AsParallel()
.Where(x => x.ColumnName.Contains(period))
.Select(x => new x.ColumnName ).FirstOrDefault();
if (QcViewColumnName != null)
period = QcViewColumnName.ColumnName;
if (period.Trim() != "")
var datarow = QCViewAlltmp.Tables[0].AsEnumerable().AsParallel()
.Where(row => row.Field<string>("GroupKey").Split('~')[0].ToUpper() == section.ToUpper()
&& row.Field<string>("GroupKey").Split('~')[1].ToUpper() == li.ToUpper()
&& row.Field<string>("Section ").ToUpper() == broker.ToUpper());
if (datarow != null && datarow.Count() > 0)
strQCPeriodValue = (datarow.FirstOrDefault()[period] != null ? datarow.FirstOrDefault()[period].ToString() : string.Empty);
if (strQCPeriodValue.Trim() != string.Empty)
comment.IgnoreData = strQCPeriodValue;
counter++;
SerializeQcComment(QCCommentlist);
toolTip1.Hide(this);
Loading data from XML file into a dataset.
If the ignoredata
field is there in QCCommentstmp
dataset table QCCommentstmp.Tables[0].Columns.Contains("IgnoreData")
then deserialize QCCommentstmp table data to list List<clsCommentPopup> QCCommentlist
.
Iterate in QCCommentlist
's data using a for
loop and finding data in QCViewAlltmp.Tables[0]
data table for each iteration.
When QCCommentlist
has 25000 data then I am iterating in all 25000 data and finding data in another data table. If data is found then I am updating data in the list. This process is getting very slow and the code is taking a long time to finish all the iteration and searching data in the data table.
Please review my code and tell me how to restructure my code, as a result, there will be the improvement in code execution speed.
If my approach is wrong then guide me with the right approach and also give me the relevant code which I can use in my above code, as a result, my routine will take minimum time to finish if I iterate in more than 25000 data. I'm looking for suggestions and better code to achieve the same task.
c#
New contributor
$endgroup$
I have a list which has 25000 data and I am iterating in all data and in each iteration, I am searching data in another data table. my whole routine is taking a long time to finish.
private void UpdateCommentFirst(string strCommentPath, string TickerName)
int counter = 0;
bool QcViewAllFileExist = false;
bool QcCommentFileExist = false;
bool AllowUpdate = false;
string savepath = Convert.ToString(ConfigurationManager.AppSettings["OutputPath"]).Trim() + TickerName + "\" + TickerName + "_QC-ViewwAll.xml";
DataSet QCCommentstmp = new DataSet();
DataSet QCViewAlltmp = new DataSet();
if (File.Exists(strCommentPath))
QCCommentstmp.ReadXml(strCommentPath);
QcCommentFileExist = true;
if (File.Exists(savepath))
QCViewAlltmp.ReadXml(savepath);
QcViewAllFileExist = true;
if (QcCommentFileExist && QcViewAllFileExist)
if (QCCommentstmp.Tables.Count > 0)
if (!QCCommentstmp.Tables[0].Columns.Contains("IgnoreData"))
AllowUpdate = true;
if (AllowUpdate)
List<clsCommentPopup> QCCommentlist = QCCommentstmp.Tables[0].AsEnumerable()
.Select(row => new clsCommentPopup
//BrokerFor,Formula,LineItem,Section,PeriodCollection
bolFollowUP = (row.Field<string>("FollowUP")) == null ? false : Convert.ToBoolean((row.Field<string>("FollowUP"))),
bolThisPeriod = (row.Field<string>("ThisPeriod")) == null ? false : Convert.ToBoolean((row.Field<string>("ThisPeriod"))),
Formula = (row.Field<string>("Formula")) == null ? string.Empty : (row.Field<string>("Formula")),
ModelValue = (row.Field<string>("ModelValue")) == null ? string.Empty : (row.Field<string>("ModelValue")),
ExternalComment = (row.Field<string>("ExternalComment")) == null ? string.Empty : (row.Field<string>("ExternalComment")),
InternalComment = (row.Field<string>("InternalComment")) == null ? string.Empty : (row.Field<string>("InternalComment")),
strEndPeriod = (row.Field<string>("EndPeriod")) == null ? string.Empty : (row.Field<string>("EndPeriod")),
strStartPeriod = (row.Field<string>("StartPeriod")) == null ? string.Empty : (row.Field<string>("StartPeriod")),
PeriodType = (row.Field<string>("PeriodType")) == null ? string.Empty : (row.Field<string>("PeriodType")),
SectionFor = (row.Field<string>("Section")) == null ? string.Empty : (row.Field<string>("Section")),
LiFor = (row.Field<string>("LineItem")) == null ? string.Empty : (row.Field<string>("LineItem")),
QcPeriodFor = (row.Field<string>("QcPeriod")) == null ? string.Empty : (row.Field<string>("QcPeriod")),
BrokerFor = (row.Field<string>("BrokerFor")) == null ? string.Empty : (row.Field<string>("BrokerFor")),
PeriodCollection = (row.Field<string>("PeriodCollection")) == null ? string.Empty : (row.Field<string>("PeriodCollection")),
boolIgnoreValue = (row.Field<string>("IgnoreValue")) == null ? false : Convert.ToBoolean((row.Field<string>("IgnoreValue"))),
IgnoreData = (!QCCommentstmp.Tables[0].Columns.Contains("IgnoreData") ? string.Empty : (row.Field<string>("IgnoreData") == null ? string.Empty : row.Field<string>("IgnoreData")))
).ToList();
if (QCCommentlist != null)
foreach (var comment in QCCommentlist)
string section = comment.SectionFor;
string li = comment.LiFor;
string broker = comment.BrokerFor;
string period = comment.PeriodCollection;
string strQCPeriodValue = "";
if (comment.boolIgnoreValue && period.Trim() != "")
var QcViewColumnName = QCViewAlltmp.Tables[0].Columns.Cast<DataColumn>().AsParallel()
.Where(x => x.ColumnName.Contains(period))
.Select(x => new x.ColumnName ).FirstOrDefault();
if (QcViewColumnName != null)
period = QcViewColumnName.ColumnName;
if (period.Trim() != "")
var datarow = QCViewAlltmp.Tables[0].AsEnumerable().AsParallel()
.Where(row => row.Field<string>("GroupKey").Split('~')[0].ToUpper() == section.ToUpper()
&& row.Field<string>("GroupKey").Split('~')[1].ToUpper() == li.ToUpper()
&& row.Field<string>("Section ").ToUpper() == broker.ToUpper());
if (datarow != null && datarow.Count() > 0)
strQCPeriodValue = (datarow.FirstOrDefault()[period] != null ? datarow.FirstOrDefault()[period].ToString() : string.Empty);
if (strQCPeriodValue.Trim() != string.Empty)
comment.IgnoreData = strQCPeriodValue;
counter++;
SerializeQcComment(QCCommentlist);
toolTip1.Hide(this);
Loading data from XML file into a dataset.
If the ignoredata
field is there in QCCommentstmp
dataset table QCCommentstmp.Tables[0].Columns.Contains("IgnoreData")
then deserialize QCCommentstmp table data to list List<clsCommentPopup> QCCommentlist
.
Iterate in QCCommentlist
's data using a for
loop and finding data in QCViewAlltmp.Tables[0]
data table for each iteration.
When QCCommentlist
has 25000 data then I am iterating in all 25000 data and finding data in another data table. If data is found then I am updating data in the list. This process is getting very slow and the code is taking a long time to finish all the iteration and searching data in the data table.
Please review my code and tell me how to restructure my code, as a result, there will be the improvement in code execution speed.
If my approach is wrong then guide me with the right approach and also give me the relevant code which I can use in my above code, as a result, my routine will take minimum time to finish if I iterate in more than 25000 data. I'm looking for suggestions and better code to achieve the same task.
c#
c#
New contributor
New contributor
edited 11 mins ago
Jamal♦
30.6k11121227
30.6k11121227
New contributor
asked 8 hours ago
user197025user197025
61
61
New contributor
New contributor
$begingroup$
Break this up into smaller functions and find where you are spending the most time. This function is too complex.
$endgroup$
– pacmaninbw
5 hours ago
add a comment |
$begingroup$
Break this up into smaller functions and find where you are spending the most time. This function is too complex.
$endgroup$
– pacmaninbw
5 hours ago
$begingroup$
Break this up into smaller functions and find where you are spending the most time. This function is too complex.
$endgroup$
– pacmaninbw
5 hours ago
$begingroup$
Break this up into smaller functions and find where you are spending the most time. This function is too complex.
$endgroup$
– pacmaninbw
5 hours ago
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
return StackExchange.using("mathjaxEditing", function ()
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
);
);
, "mathjax-editing");
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "196"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
user197025 is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f216990%2fiterating-in-a-list-of-data-and-search-data-in-another-datatable%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
user197025 is a new contributor. Be nice, and check out our Code of Conduct.
user197025 is a new contributor. Be nice, and check out our Code of Conduct.
user197025 is a new contributor. Be nice, and check out our Code of Conduct.
user197025 is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Code Review Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f216990%2fiterating-in-a-list-of-data-and-search-data-in-another-datatable%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
$begingroup$
Break this up into smaller functions and find where you are spending the most time. This function is too complex.
$endgroup$
– pacmaninbw
5 hours ago